Registry / testing / fetch-http-message

fetch-http-message

JSON →
library1.0.12jsnpmunverified

Generate an HTTP message string using the Fetch API. Compatible with both browser and Node.js environments. Current stable version is 1.0.12. It takes a URL and options (method, headers, body) and returns a raw HTTP request string. Differentiates by being a lightweight, TypeScript-ready utility for creating HTTP message strings without making actual network requests.

npm install fetch-http-message
INSTALL
IMPORT
SIG · FETCH-HTTP-MESSAGE
F
fetch-http-message
testingjavascriptv1.0.12
harness data pending
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.

default
import fetchMessage from 'fetch-http-message'
const fetchMessage = require('fetch-http-message')
Only default export exists; no named exports.

Generates an HTTP request message string from a URL and Fetch API options.

import fetchMessage from 'fetch-http-message'; const headers = { 'Content-Type': 'application/json' }; const body = JSON.stringify({ key: 'value' }); const message = fetchMessage('https://api.example.com/data', { method: 'POST', headers, body }); console.log(message); // Output: POST https://api.example.com/data HTTP/1.1\r\nContent-Type: application/json\r\n\r\n{"key":"value"}
Debug
Known issues
gotchaThe package uses the Fetch API's Headers object but does not validate header names or values; invalid headers may produce malformed output.
fix
Ensure header names are valid HTTP header names and values are strings.
affects: all
gotchaOnly the 'method', 'headers', and 'body' options are used; all other Fetch API options (e.g., mode, credentials, cache) are ignored.
fix
Only provide those three options if they are intended to be used.
affects: all
gotchaThe body is not validated; passing non-string or non-null body may produce unexpected results.
fix
Pass a string or null/undefined as body.
affects: all
Errors
Common errors & fixes
Error: fetchMessage is not a function (or TypeError: fetchMessage is not a function)
Using a named import instead of default import.
fix
Use default import: import fetchMessage from 'fetch-http-message'
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fetch-http-message — npm install fetch-http-message · libregistry