What is Axios?

Axios is a lightweight HTTP client based on the XMLHttpRequests service. It is similar to the Fetch API and is used to perform HTTP requests.

svg viewer

Installing Axios

The following command can be used for installing axios using npm:

npm install axios

Making an HTTP GET request

Axios can be used to perform a simple GET request. The syntax for this is​:

axios({
  url:'https://www.educative.io/',
  method: 'get'
})

Making an HTTP POST request

Axios can similarly be used to perform a simple POST request. We can also send parameters in an object using the POST request. The syntax for this is:

axios({
  method: 'post',
  url: '/signup',
  data: {
    user: 'abcd1234',
    pass: 'pwd1234'
  }
})

Advantage of Axios over Fetch API

  • supports older browsers
  • has a way to abort a request
  • has a way to set a response timeout
  • has built-in CSRF protection
  • supports upload progress
  • performs automatic JSON data transformation.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved