safak / youtube

5.04k stars 5.47k forks source link

Err when fetching products in console #87

Closed lanaarnous01 closed 2 years ago

lanaarnous01 commented 2 years ago

image

` useEffect(() => {

    const getProducts = async ()=> {
        try{

            const res = await axios.get("http://localhost:5000/api/products");
            console.log(res);
        } catch(err){

        }
    }
    getProducts();
}, [category])`

after coding use effect and fetching products, the error appears on my console as the api and client are running at the same time

Anyone knows whats the issue?

AliCreator commented 2 years ago

Two points: first try to console log the error on catch(err). It will give more details. Second, did you add "proxy" on package.json? Why did you add category as a dependency on your useEffect(). I don't see any place you use it.