React JS
June 3, 2026 1 min read

How to create Http request using axios

HS
HEMANT SINGH
Technical Writer & Educator

Axios is a popular JavaScript library used for making HTTP requests from web browsers or Node.js environments. It simplifies the process of sending asynchronous HTTP requests to a server and handling responses.

 

Install axios package

npm i axios

import axios package

import axios from "axios"

Make GET request using axios.

axios.get("url")
.then(response=>console.log(response))
.catch(error=>console.log(error))

 

Make POST request using axios

axios.get("url", data, {
headers:{
  'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then(response=>console.log(response))
.catch(error=>console.log(error))