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.
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:
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:
- 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.