A comprehensive toolkit for making HTTP requests using Axios 1.x, a promise-based HTTP client for browser and Node.js environments. Use when building applications that require REST API communication, file uploads/downloads, request/response interception, custom headers, authentication, form data handling, progress tracking, or advanced features like rate limiting and HTTP/2 support.
A comprehensive toolkit for making HTTP requests using Axios 1.x, a promise-based HTTP client for browser and Node.js environments. Use when building applications that require REST API communication, file uploads/downloads, request/response interception, custom headers, authentication, form data handling, progress tracking, or advanced features like rate limiting and HTTP/2 support.
Axios is a promise-based HTTP client for the browser and Node.js. It provides a simple, consistent API for making HTTP requests across environments — using XMLHttpRequest in browsers, the native http/https modules in Node.js, and optionally the Fetch API. It supports interceptors, automatic JSON handling, form serialization, request cancellation, progress tracking, and TypeScript out of the box.
Key characteristics:
Isomorphic — same API works in browser and Node.js
Promise-based — full support for async/await and .then() chains
Interceptor system — middleware-like hooks for request/response lifecycle
Automatic serialization — JSON, multipart/form-data, and x-www-form-urlencoded
Progress capturing — upload/download progress with speed and ETA (browser + Node.js)
Rate limiting — bandwidth capping in Node.js via maxRate
Fetch adapter — optional first-class Fetch API support (v1.7.0+)
HTTP/2 — experimental support in Node.js (v1.13.0+)
When to Use
Making REST API calls from frontend or backend JavaScript code
Building isomorphic/universal applications that share HTTP logic between browser and server
Needing request/response interceptors for auth tokens, logging, or error handling
Uploading files with progress tracking
Requiring automatic form data serialization (FormData, URLSearchParams)
Implementing retry logic, token refresh, or rate limiting
Working in environments that need the Fetch adapter (Cloudflare Workers, Deno, Tauri, SvelteKit)
Core Concepts
Making Requests
Every axios request returns a standard ES6 Promise. The recommended approach is async/await:
Every resolved request returns a response with this shape:
{
data: {}, // Response body (parsed JSON by default)status: 200, // HTTP status codestatusText: "OK", // HTTP status textheaders: {}, // Response headers (AxiosHeaders instance, lower-cased keys)config: {}, // The full config used for this requestrequest: {} // Underlying request object (XMLHttpRequest or http.ClientRequest)
}