Axios
Promise-based HTTP client for browser and Node.js with automatic JSON transformation, interceptors, and request cancellation
Table of Contents
New to Async JavaScript? Start Here First!
This sheet covers the Fetch API for making HTTP requests. If you're new to promises, async/await, or asynchronous JavaScript patterns, we recommend starting with our async JavaScript fundamentals sheet first.
Start with Async JavaScript FundamentalsInstallation & Basic Requests
Installation & Setup
Install Axios and create your first request
HTTP Request Methods
Perform GET, POST, PUT, PATCH, and DELETE requests
Request Configuration
Configure timeout, headers, query params, and more
Interceptors & Error Handling
Request Interceptors
Modify requests before they are sent
Response Interceptors
Transform responses and handle errors globally
Error Handling
Handle and diagnose different error types
Request Cancellation & Timeout
Request Cancellation with AbortController
Cancel in-flight requests using modern AbortController API
Timeout Configuration
Set connection and response timeouts to prevent hanging
Advanced Patterns
TypeScript Integration
Type-safe API calls with TypeScript generics
File Uploads & Downloads
Handle file uploads with progress and file downloads
Authentication Patterns
Implement JWT refresh, bearer tokens, and auth interceptors