| What it is | Human-friendly and powerful HTTP request library for Node.js | Ajax for Node.js and browsers (JS HTTP client) | An HTTP/1.1 client, written from scratch for Node.js | A light-weight module that brings the Fetch API to Node.js |
| Features | - promise API and stream API
- retries on failure, on by default
- advanced timeouts per request phase
- pagination API
- RFC 7234 compliant caching
- cookies
- HTTP/2 support
- proxy support and Unix domain sockets
- All 15 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
| - request, stream, pipeline, connect and upgrade APIs
- WHATWG fetch implementation, the one built into Node.js since v18
- Client, Pool, BalancedPool, RoundRobinPool and Agent dispatchers with keep-alive
- HTTP/2 when the server prefers it through ALPN (allowH2), and H2CClient for cleartext HTTP/2
- optional HTTP/1.1 pipelining
- ProxyAgent, EnvHttpProxyAgent (http_proxy, https_proxy, no_proxy) and Socks5ProxyAgent
- RetryAgent and retry handler
- interceptors: redirect, retry, dump, dns, cache, decompress, responseError and deduplicate
- All 19 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
|
| Limitations | - Doesn't run in the browser: it's an HTTP library for Node.js only
- Doesn't provide a CommonJS export: it's native ESM, so CommonJS projects must convert to ESM
| | - Doesn't work without WebAssembly: its HTTP/1 parser needs it, so requests fail with ERR_WEBASSEMBLY_NOT_SUPPORTED under --jitless
- Doesn't support the Expect: 100-continue request header: it sends the body at once and ignores 100 Continue
- Doesn't implement CORS in fetch: no preflight requests or Access-Control-Allow-Origin checks
| - 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
|