Axios
Axios is a promise-based HTTP client for the browser and Node.js with automatic JSON data transformation and request/response interceptors.
APIs
Axios
Axios is a promise-based HTTP client for the browser and Node.js with automatic JSON data transformation and request/response interceptors.
Features
Built on promises for clean async/await and .then() chaining patterns.
Works in both browser and Node.js environments with automatic XHR/http adapter selection.
Automatically serializes JavaScript objects to JSON and parses JSON responses.
Add custom logic to requests and responses before they are handled.
Cancel in-flight requests using AbortController or the CancelToken API.
Built-in client-side XSRF protection support.
Configure request timeouts for automatic cancellation of long-running requests.
Track upload and download progress with onUploadProgress and onDownloadProgress callbacks.
Use Cases
Consume RESTful APIs from frontend applications and Node.js servers.
Upload files with progress tracking to backend services.
Add auth tokens and headers automatically via request interceptors.
Fetch data in React, Vue, Angular, and other JavaScript frameworks.
Test API integrations in Node.js scripts and test suites.
Integrations
Commonly used for data fetching in React applications with hooks.
Official recommendation for HTTP requests in Vue.js applications.
Used for server-side HTTP requests with the native http/https adapter.
First-class TypeScript support with bundled type definitions.
Easily mocked with jest.mock() for unit testing HTTP-dependent code.