Hi Thiago, Thank you so much for this great tutorial. I followed the whole tutorial exactly as you mentioned and at the end when inserting the post requests to include some products... the console was showing this message:
GET localhost:3000/api/product 404 (Not Found)
dispatchXhrRequest @ xhr.js:178 ........
and then I changed in productService.js, axios.get("/api/product) for axios.get(http://localhost:5000/api/product) and the whole app worked!
I have the proxy in the package.json included and everything...but not sure if I missed something..do you know why this happens?Thank you in advance!!!
Are you getting this error in the front-end console or is it in an HTTP client?
If this is in your react app, it seems like something is wrong with the proxy config.
I think I found the issue. I had included the sentence "proxy": "localhost:5000" inside the package.json belonging to the server, and not inside the package.json of the client(react app). May be that one the problem Thiago? Because now I´m not getting any errors.
Hi Thiago, Thank you so much for this great tutorial. I followed the whole tutorial exactly as you mentioned and at the end when inserting the post requests to include some products... the console was showing this message:
GET localhost:3000/api/product 404 (Not Found)
dispatchXhrRequest @ xhr.js:178 ........
and then I changed in productService.js, axios.get("/api/product) for axios.get(
http://localhost:5000/api/product
) and the whole app worked!I have the proxy in the package.json included and everything...but not sure if I missed something..do you know why this happens?Thank you in advance!!!
Another thing, you should not include the localhost in your axios.get function call.
It should be axios.get("/api/product", ...).
The base URL definition is already set at the beginning of the application when we build the server and define a port, in this case 5000.
Hi Oscar,
Are you getting this error in the front-end console or is it in an HTTP client?
If this is in your react app, it seems like something is wrong with the proxy config.
It was showing this error inside Chrome Devtools (where localhost:3000).
Are you able to insert data through an HTTP client like Insomnia or postman?
I think I found the issue. I had included the sentence "proxy": "localhost:5000" inside the package.json belonging to the server, and not inside the package.json of the client(react app). May be that one the problem Thiago? Because now I´m not getting any errors.
That was it, for sure Oscar.
Let me know if you have any other questions! :)