How to fetch data using Axios Http Get Request in React Js? #axios #api #get #request #advantages #json #http #reactjs
How to fetch data using Axios - Http Get Request in React Js?
In one of my previous post, I had explained all about Fetch() method to retrieve data from api server.
In this post, I am going to demystify how to achieve same thing using axios. Axios has many advantages over fetch() method.
1) Axios has the ability to intercept HTTP request.
2) With axios.all() method, you can make simultaneous requests, simply send an array of request to this method, then use axios.spread() method to assign the properties of the response array to separate varialbes.
3) Axios automatically stringifies the data when sending requests, as in fetch() method, you would have to do it manually.
4) You can set response timeout.
5) Support backward compatibility, this is because it uses XMLhttprequest under the hood.










