Using Axios with React

Christina Williams
2 min readMar 8, 2021

React is JavaScript, which can send network (HTTP) requests to the server.

Fetch is a method that sends one simple argument to the path and resource you need to make a request from and then returns a promise that will return a response as soon as the server responds. So, you are “fetching” a request and returning a “promise” from the server that will give you a response, which is in the form of an object.

Axios is a JavaScript library. Axios can be used to make HTTP requests. It is often preferred by web developers over the fetch method because it provides several features not available with the fetch method.

Some of the Axios features include:

- It has the ability to cancel requests

- It can be used to intercept HTTP requests and responses

- It enables client-side protection

-It automatically transforms requests and data

-It has built-in support for download progress

When using Axios, you must install it, for example, with react, you would type in your command line npm install axios.

--

--