Promise based HTTP client for the browser and node.js
Features
- Make XMLHttpRequests from the browser
- Make http requests from node.js
- Supports the Promise API
- Intercept request and response
- Transform request and response data
- Cancel requests
- Automatic transforms for JSON data
- Automatic data object serialization to
multipart/form-data
andx-www-form-urlencoded
body encodings - Client side support for protecting against XSRF
Browser Support
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
Installing
Package manager
Using npm:
$ npm install axios
Using bower:
$ bower install axios
Using yarn:
$ yarn add axios
Using pnpm:
$ pnpm add axios
Once the package is installed, you can import the library using import
or require
approach:
import axios, {isCancel, AxiosError} from 'axios';
You can also use the default export, since the named export is just a re-export from the Axios factory:
const axios = require('axios');
console.log(axios.isCancel('something'));
If you use require
for importing, only default export is available:
const axios = require('axios');
console.log(axios.isCancel('something'));
For cases where something went wrong when trying to import a module into a custom or legacy environment,
you can try importing the module package directly:
const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017)
// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017)
No reviews found!
No comments found for this product. Be the first to comment!