Open navigation menu

Axios

Promise-based HTTP client for browser and Node.js with interceptors, transforms, and automatic JSON parsing.

Version: v1.7

Official Documentation ↗

Installation

npmnpm install axios
pnpmpnpm add axios
yarnyarn add axios

Methods

FAQ

Why use Axios instead of the Fetch API?
Axios provides automatic JSON transformation, request/response interceptors, timeout handling, progress tracking, and error objects with response data. The Fetch API requires manual JSON parsing and lacks interceptors and timeouts.
How do I cancel requests in Axios?
Use AbortController (Axios v0.22+). Pass { signal: controller.signal } in the config and call controller.abort() to cancel. This replaces the deprecated CancelToken API.
Is Axios tree-shakeable?
No. Axios is not tree-shakeable because it is a single monolithic instance. For smaller bundles, consider using the Fetch API or ky for specific use cases.