What is Axios?

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

Axios is a word-based HTTP client that runs in both the browser and node.js environment. Provides a single API for the XMLHttpRequests and node http interface. In addition, ES6 sends requests using a multifill for syntax.

Installing Axios

The following command can be used to install axios using Npm:

npm install axios

Make an HTTP GET request

Axios is a simple GETcan be used to perform requests. This syntax:

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

Make an HTTP POST request

Axios is similarly simple. POSTcan be used to perform requests. POSTWe can also send parameters on an object using the request . This syntax:

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

Axios' advantage

  • Supports older browsers
  • There's a way to cancel a request.
  • The response timeout can be set.
  • It has built-in CSRF protection.
  • Supports installation progress.
  • Performs automatic JSON data conversion.

  Quote

KARABAY A, 2020 . What is Axios ?,

https://www.karabayyazilim.com/blog/javascript/axios-nedir-2020-05-21-115817

(Accessed May 21, 2020).


  Share this post

Comments (0)

Comment

Subscribe
Sign up for the email newsletter to be the first to know about my blog posts