Fetch-parse is a mixin for the Fetch API that automatically buffers response bodies and optionally parses them based on the Content-Type header. Version 1.1.0 (latest) is stable with no active development. It supports custom parsers and shorthands for JSON and XML. Key differentiator: eliminates manual res.text()/res.json() calls and provides content-type-driven parsing out of the box.
npm install fetch-parseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage: wraps native fetch to automatically buffer and parse response bodies based on Content-Type.
Specify explicit media type patterns for full control, e.g., fetchParse(fetch, { 'text/*': true, 'application/xml': true, '*/*': true }).Pass a function instead of true for custom parsing, e.g., fetchParse(fetch, { 'text/markdown': (res) => res.text() }).Pass fetch explicitly: fetchParse(require('node-fetch'), ...) for Node.js or ensure browser fetch is polyfilled.Install node-fetch and pass it to fetchParse: const fetch = require('node-fetch'); const apiFetch = fetchParse(fetch);Use import or set type: module in package.json, or use a dynamic import: const fetchParse = (await import('fetch-parse')).default;Ensure you call the wrapped function apiFetch instead of fetch directly.