🌐
HTTP45M+/wkMIT

axios

Axios is a promise-based HTTP client for the browser and Node.js that provides an elegant and powerful API for making HTTP requests. It features automatic JSON

Installation

npm
npm install axios
yarn
yarn add axios
pnpm
pnpm add axios

Import

ESM
import axios from 'axios';

Quick Example

usage
const response = await axios.get('/api/users');
console.log(response.data);

await axios.post('/api/users', {
  name: 'John',
  email: '[email protected]',
});

About axios

Axios is a promise-based HTTP client for the browser and Node.js that provides an elegant and powerful API for making HTTP requests. It features automatic JSON transformation for request and response data, request and response interceptors for global handling of authentication headers and error responses, and built-in CSRF protection through XSRF token support. Axios supports request cancellation using AbortController, timeout configuration, upload and download progress events, and automatic request retry through community plugins. The library works identically in both browser and Node.js environments by using XMLHttpRequest in browsers and the http module in Node.js. Axios instances can be created with custom default configurations for base URLs, headers, and timeout values, making it easy to configure different API clients for different services. The interceptor system allows global request and response transformation, which is commonly used for attaching authentication tokens, refreshing expired tokens, and handling error responses consistently. Axios remains one of the most downloaded npm packages despite the growth of the native Fetch API.

Quick Facts

Packageaxios
CategoryHTTP
Weekly Downloads45M+
LicenseMIT
Installnpm install axios

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.