Axios vs fetch: Which HTTP Client?
Axios is a feature-rich HTTP library with interceptors and auto-JSON; fetch is the native, zero-dependency browser and Node primitive.
Axios provides conveniences fetch lacks out of the box: automatic JSON parsing, request/response interceptors, timeouts, upload progress, and consistent error handling on non-2xx responses, at the cost of a dependency. fetch is built into modern browsers and Node, has no install footprint, and supports streaming, but needs manual JSON handling and does not reject on HTTP errors. Axios wins on convenience and features; fetch wins on zero dependencies and platform nativeness.
| Axios | fetch | |
|---|---|---|
| Dependency | External library | Native (no install) |
| JSON | Automatic | Manual (.json()) |
| Interceptors | Built-in | Manual wrappers |
| Error on 4xx/5xx | Rejects | Resolves (check ok) |
| Best for | Convenience, interceptors | Zero-dependency, native |
Use case and features
Axios suits apps wanting interceptors, automatic JSON, timeouts, and uniform error handling without writing wrappers. fetch suits teams minimizing dependencies and bundle size, or wanting platform-native streaming, willing to add thin helpers for JSON and error handling.
Testing and CI
Both mock cleanly with MSW or nock; fetch is now native in Node test environments. Either runs on managed runners, where faster runners shorten HTTP-mocked integration suites.
The verdict
Want interceptors, auto-JSON, and uniform error handling: Axios. Want zero dependencies and platform-native fetch: the native API (optionally with a thin wrapper). Axios trades a dependency for convenience; fetch trades convenience for nativeness.