'Page not returning data using React-Redux
So I am creating a pizza website but after trying to get the data from the database it is showing an error something like this
this is the Action and Routes code: Action Routes
I am following a Youtube Tutorial https://www.youtube.com/watch?v=p4mYkWuFs80&list=PLN4MUG0f6hp1lTDxczIbp5WGzvoA5UCse&index=2
he told to restart the server in the video but even restarting its not working.
Solution 1:[1]
Please make sure you have added the proxy variable in your package.json. The person is adding it on timestamp 6:45. Example:
package.json
"proxy" : "http://localhost:8000/"
And that is why your axios.get has only "/api/getallpizzas"
Other option is to add the full path in your axios.get like so:
axios.get('http://localhost:8000/api/getallpizzas')
.then((response)=>{
console.log(response);
dispatch({type:'GET_PIZZAS_SUCCES', payload: response.data})
})
.catch((error)=>{
dispatch({type:'GET_PIZZAS_FAILED', payload:error})
})
Another possible error might be that your server is not running.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stefan Georgiev |
