| What it is | A better fetch API. Works on node, browser, and workers. | A light-weight module that brings the Fetch API to Node.js | Promise based HTTP client for the browser and node.js | Ajax for Node.js and browsers (JS HTTP client) |
| Features | - automatic JSON parsing, Blob for binary content types
- automatic JSON body stringifying and headers
- FetchError with the parsed error body
- retries on configurable status codes, not by default for POST, PUT, PATCH and DELETE
- timeout option
- baseURL and query options
- typed responses
- onRequest, onRequestError, onResponse and onResponseError interceptors
- All 12 features
| - window.fetch-compatible API
- native promises and async functions
- Node.js streams for request and response bodies
- gzip, deflate and brotli decoding
- redirect limit and response size limit
- FetchError and AbortError types
- AbortSignal cancellation
- custom http.Agent
- All 9 features
| - XMLHttpRequest and fetch in browsers, http module in Node.js
- Promise API with async/await
- request and response interceptors
- request and response data transforms
- cancellation with AbortController
- automatic JSON serialization and parsing
- multipart/form-data and URL-encoded serialization
- upload and download progress events
- All 14 features
| - same chainable API in browsers and Node.js
- callbacks, promises and async/await
- JSON and URL-encoded bodies
- multipart attachments and fields
- retries for transient failures
- deadline and response timeouts
- Basic and Bearer auth
- agents that keep cookies
- All 14 features
|
| Limitations | | - Doesn't load with require() in CommonJS from v3: version 3 is ESM only, and v2 stays CommonJS-compatible
- Doesn't keep cookies between requests: there's no cookie store, so you read Set-Cookie headers yourself
- Doesn't cache responses: there's no built-in HTTP caching
| - HTTP/2 support is experimental: only the Node.js http adapter has it, and behaviour depends on the runtime and Node.js version
| |