A lightweight HTTP client wrapper around the Fetch API with middleware support, enabling synchronous and asynchronous pre-request and post-response hooks. Version 1.1.0 is the current stable release with no active development since 2017. It distinguishes itself from fetch-plus and http-client by allowing asynchronous middleware (e.g., for token retrieval) and includes built-in middleware for JSON handling, query string construction, and path variable substitution. Suitable for browser and React Native environments.
npm install fetch-http-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a client with JSON and query middleware, adds an auth header, requests a user by path variable and query parameter.
Always return request from middleware: client.addMiddleware(req => { ...; return req; })client.post('data', { body: { key: 'value' } }) will fail; stringify manually: body: JSON.stringify({ key: 'value' })Ensure uri params match: client.get('users/{userId}', { uriParams: { userId: 123 } })Consider using ky, got, or native fetch with manual middleware.
Add json() middleware and ensure body is a string (JSON.stringify).
Initialize headers: request.options = request.options || {}; request.options.headers = request.options.headers || {};Install 'node-fetch' and set global.fetch = require('node-fetch') before using fetch-http-client.No dependency data recorded yet.