Registry / http-networking / http-client

http-client

JSON →
library4.3.1jsnpmunverified

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.

http-networkingweb-framework
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM import is recommended; CommonJS requires destructuring the require.

import { createFetch } from 'http-client'

base is a named export, not the default.

import { base } from 'http-client'

All exports are from the main package, no subpath imports.

import { createStack } from 'http-client'

Creates a typed fetch client with base URL, Accept header, and JSON parsing middleware.

import { createFetch, base, accept, parse } from 'http-client' const fetch = createFetch( base('https://api.example.com'), accept('application/json'), parse('json') ) fetch('/users/1') .then(response => { console.log(response.body) // parsed JSON }) .catch(error => { console.error('Request failed:', error) })
Debug
Known footguns
gotchaRequires a global fetch polyfill (e.g., isomorphic-fetch) in environments without native fetch (e.g., older Node versions).
breakingVersion 3.x dropped support for Node < 10 and removed deprecated middleware 'headers' in favor of 'accept' and 'auth'.
gotchaMiddleware order matters; for example, 'parse' must come after middleware that sets response headers (like 'accept' or 'auth').
deprecatedThe 'headers' middleware was deprecated in v3.0 and removed in v4.0.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources