json-fetch is a lightweight wrapper around the ES6 fetch API that simplifies interacting with JSON APIs. It automatically serializes request bodies to JSON and sets appropriate Content-Type headers, parses responses as JSON when Content-Type is application/json, includes credentials by default, and supports configurable retry logic via the promise-retry library. Current stable version: 9.0.10. Release cadence is irregular. Key differentiators: built-in retry strategies for 5xx errors and network errors, request/response lifecycle callbacks, TypeScript type declarations (requires DOM lib), and a simple API that reduces boilerplate for JSON API calls. Supports Node.js >=12.
npm install json-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic POST request with JSON body, expected status validation, retry on network errors, and request lifecycle callbacks.
Import as default function directly: `import jsonFetch from 'json-fetch'`.
Upgrade Node.js to v12 or later.
Add `"lib": ["DOM", "ES2020"]` to tsconfig.json.
Keep using as-is; no immediate action needed.
Ensure your API returns Content-Type: application/json or handle manually.
Run `npm install json-fetch` or `yarn add json-fetch`. Ensure no path typo.
Use `import jsonFetch from 'json-fetch'` or switch to dynamic import.
Use `import jsonFetch from 'json-fetch'` directly.
Use `import { retriers } from 'json-fetch'`.