axios
Promise based HTTP client for the browser and node.js
The native fetch API is verbose for the patterns every app uses: you need to manually check response.ok, call response.json(), set Content-Type headers on every POST, and handle errors yourself. Axios wraps fetch with sensible defaults and adds features like request/response interceptors that are hard to implement cleanly with fetch.
Axios is a promise-based HTTP client that treats requests as a pipeline: request interceptors run before the request is sent, the request goes out, then response interceptors run on the way back. This makes cross-cutting concerns like auth tokens and error logging trivially easy to add in one place.
Install axios
npm install axios
import { } from 'axios';Use it when
Use axios when you need request/response interceptors (auth headers, logging, retry logic), want automatic JSON serialisation/deserialisation, need to cancel in-flight requests, or want consistent behaviour between browser and Node.js environments.
Skip it when
For simple requests in modern apps, fetch is built-in and perfectly adequate. For lightweight browser-only code, ky is a smaller alternative. React Query or SWR abstract data fetching further โ prefer those when you also need caching and state management.
Ready to explore the full API?
See every class, function, and relationship in an interactive graph.