DEV Community

loading...
Cover image for How to use Axios with ReactJS Application

How to use Axios with ReactJS Application

Pankaj Kumar
I am javascript developer having experience of 8 years+ on different frameworks/libraries of Javascaipt. I am interested to explore more in js.
・1 min read

In this article, I am going to explain how to use Axios for GET, POST, PUT and other HTTP requests in React.js application. I will use MongoDB, Node, and Express.js to create a backend server for the React app.

I assume that you have already available the above tools/frameworks and you are familiar with all the above that what individually actually does.

As we know that we can easily start working on React.js with the create-react-app tool. Here I will skip this because you would be familiar with the basic stuff of React.js. If you are not aware of creating the React.js app with the above tool.

What is Axios?

Axios is a popular, promise-based HTTP client that sports an easy-to-use API and can be used in both the browser and Node.js. We can use Axios with React to make requests to an API, return data from the API, and then do things with that data in our React app.

With Axios, A developer can also take advantage of async/await for more readable asynchronous code.

Here we will use JSON placeholder API for fetching the list of dummy users.

Install Axios

At first, we need to install Axios into the react project. Run below command to install it in the project.
yarn add axios
npm install axios
For more follow the link below.

This articles was originally posted on jsonworld.com

Find here the demo video tutorial

Thanks!

Discussion (0)