A lightweight library for composing HTTP clients using JavaScript's fetch API. Current stable version is 4.3.1, released with moderate cadence. It provides a middleware-based approach to extend and customize fetch behavior, supporting both client and server environments. Key differentiators include full preservation of fetch API capabilities, an extendable middleware API, and identical usage across Node.js and browsers. Unlike heavier alternatives like axios or superagent, http-client leans on the native fetch standard, allowing polyfills such as isomorphic-fetch for environments without global fetch.
npm install http-clientVerified import paths — ran on the pinned version, not inferred.
Creates a typed fetch client with base URL, Accept header, and JSON parsing middleware.
Install and import a polyfill like isomorphic-fetch before using http-client.
Update to v4.x; replace 'headers' middleware with explicit 'accept' and 'auth' calls.
Place 'parse' after all middleware that modifies request headers.
Use 'accept' and 'auth' middleware individually.
Install and import isomorphic-fetch: `import 'isomorphic-fetch'` before using http-client.
Ensure each middleware imported correctly and is a function.
Add parse('json') middleware to the fetch client stack.No dependency data recorded yet.