Isomorphic fetch wrapper that automatically parses JSON responses. Version 2.0.0 wraps cross-fetch and adds Zod integration via getFetchFn. It returns JSONValue or undefined, and supports custom schemas. Compared to raw fetch, it eliminates boilerplate for JSON parsing and error handling. Maintained by bconnorwhite, with regular updates.
npm install cross-fetch-jsonNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic fetchJSON usage and typed fetch with Zod schema via getFetchFn.
Check response type or use getFetchFn with a schema to ensure non-null.
Design schema to accept the full response shape, or use .passthrough() for unknown keys.
Update imports; use same API but check cross-fetch documentation for edge cases.
Change import to named: import { fetchJSON } from 'cross-fetch-json'.Run 'npm install cross-fetch-json' or ensure your bundler resolves node_modules.
Change to named import: import { fetchJSON } from 'cross-fetch-json'.Add type guard or use getFetchFn with a Zod schema.