Registry / devops / zy-fetch

zy-fetch

JSON →
library1.8.3jsnpmunverified

A fetch API-based HTTP client for browser and Node.js that supports request/response interceptors, automatic transform, timeout, and retry. Current stable version is 1.8.3. It uses XMLHttpRequest as a fallback in older browsers and node-fetch in Node.js. Key differentiators include built-in support for interceptors, automatic search params building, and concurrency methods like fetch.all and fetch.spread. The library offers global configuration and instance creation similar to axios but built on top of the fetch API.

npm install zy-fetch
INSTALL
IMPORT
SIG · ZY-FETCH
Z
zy-fetch
devopsjavascriptv1.8.3
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.

zyFetch
import 'zy-fetch'
import zyFetch from 'zy-fetch'
Global import replaces window.fetch or global.fetch with its own fetch function. Do not use as default import.
zyFetch
import zyFetch from 'zy-fetch/lib/zyFetchs'
import { zyFetch } from 'zy-fetch'
Module import uses a specific path. Default import from lib/zyFetchs gives the fetch object as default export.
fetch
import 'zy-fetch'; fetch.get(...)
const fetch = require('zy-fetch'); fetch.get(...)
Import the module globally to use fetch methods directly. CommonJS require will not expose methods as expected.

Shows global import, GET/POST requests, interceptor setup, and instance creation with base URL and timeout.

import 'zy-fetch' // GET request fetch.get('https://api.example.com/data?userid=123') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error)) // POST request with body fetch.post('https://api.example.com/data', { key: 'value' }) .then(response => response.json()) .then(data => console.log(data)) // Using interceptors fetch.interceptors.request.use(config => { config.headers['Authorization'] = 'Bearer ' + (process.env.API_KEY ?? ''); return config; }); // Instance with custom config const instance = fetch.create({ baseUrl: 'https://api.example.com', timeout: 5000 }); instance.get('/users').then(res => res.json()).then(console.log);
Debug
Known issues
gotchaGlobal import replaces native fetch. After import 'zy-fetch', window.fetch or global.fetch is replaced by zy-fetch's version.
fix
Use import zyFetch from 'zy-fetch/lib/zyFetchs' for module-local use without polluting global scope.
affects: >=1.0.0
deprecatedThe fetch.all method is deprecated in favor of Promise.all.
fix
Use Promise.all(arrayOfPromises) instead of fetch.all.
affects: >=1.8.0
breakingIn v1.7.0+, the baseUrl config key was renamed from baseUrl to baseUrl (no change, but note that baseUrl was previously baseUrl? actually no breaking change). Version jump from 1.6.x to 1.7.0 may include breaking changes not documented in README.
fix
Check CHANGELOG for breaking changes when upgrading from 1.6.x.
affects: >=1.7.0
gotchaThe fetch.spread method expects an array of responses, but order is based on fetch.all resolution order, not the order of calls.
fix
Use fetch.allByOrder if order matters.
affects: >=1.0.0
gotchaWhen using node, node-fetch v2 is required as a peer dependency. Not included by default.
fix
Run 'npm install node-fetch' for Node.js support.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: fetch.get is not a function
Importing as default export from 'zy-fetch' returns an object, not the fetch function with methods.
fix
Use import 'zy-fetch' for global import, or import zyFetch from 'zy-fetch/lib/zyFetchs'.
Uncaught ReferenceError: fetch is not defined
In Node.js, global fetch is not polyfilled. zy-fetch requires node-fetch.
fix
Install node-fetch: npm install node-fetch.
fetch.all is not a function
Possibly using an older version where fetch.all does not exist.
fix
Upgrade to latest version. Alternatively, use Promise.all.
Upgrade
Version history
1.8.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources
zy-fetch — npm install zy-fetch · libregistry