Registry / devops / za-fetch-api

za-fetch-api

JSON →
library2.7.2jsnpmunverified

A lightweight, Fetch API-like wrapper for making AJAX requests in Node.js or the browser, currently at version 2.7.2. Provides a familiar fetch-style interface with extended options like request cancellation, retries, timeout, and interceptors. Maintained actively with monthly releases. Differentiates itself from similar libraries (e.g., axios, ky) by its minimal overhead and strict adherence to the Fetch API specification, while adding ergonomic features for error handling and response transformation.

npm install za-fetch-api
INSTALL
IMPORT
SIG · ZA-FETCH-API
Z
za-fetch-api
devopsjavascriptv2.7.2
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.

zaFetch
import { zaFetch } from 'za-fetch-api'
Default export not available. Use named import.
createZaFetch
import { createZaFetch } from 'za-fetch-api'
Factory function to create a custom instance with base config.
ZaFetchError
import { ZaFetchError } from 'za-fetch-api'
Error class for request failures.

Shows basic GET request with retries and timeout using zaFetch, including error handling with ZaFetchError.

import { zaFetch } from 'za-fetch-api'; async function fetchData() { try { const response = await zaFetch('https://api.example.com/data', { method: 'GET', headers: { 'Content-Type': 'application/json' }, retries: 3, retryDelay: 1000, timeout: 5000, }); const data = await response.json(); console.log(data); } catch (error) { if (error instanceof ZaFetchError) { console.error('Request failed:', error.message); } } } fetchData();
Debug
Known issues
breakingVersion 2.x dropped support for Node.js < 14.
fix
Upgrade Node.js to 14 or higher.
affects: >=2.0.0
deprecatedThe 'interceptors' option in zaFetch is deprecated; use 'createZaFetch' with interceptors parameter.
fix
Replace 'zaFetch(url, { interceptors: [...] })' with 'const client = createZaFetch({ interceptors: [...] }); client(url, ...)'.
affects: >=2.5.0
gotchaBy default, zaFetch rejects on non-2xx status codes. To get the response regardless, pass 'validateStatus: () => true'.
fix
Add option 'validateStatus: (status) => true' to treat all statuses as success.
affects: >=2.0.0
gotchaWhen using 'retries', the library will retry on network errors only, not on HTTP errors (e.g., 4xx).
fix
Custom retry logic needed for HTTP errors; consider using interceptors to retry on specific status codes.
affects: >=2.0.0
gotchaThe 'timeout' option is in milliseconds and will abort the request if not completed in time, but the timeout is reset on each retry attempt.
fix
Set timeout as the total maximum time per attempt; for a global timeout across retries, implement manual logic.
affects: >=2.0.0
Errors
Common errors & fixes
ZaFetchError: Request timed out after 5000ms
The request took longer than the specified timeout.
fix
Increase the timeout value or optimize the request.
TypeError: Failed to parse URL from undefined
The URL argument is undefined or null.
fix
Ensure the URL is a valid string: const response = await zaFetch('https://api.example.com');
Error: Too many retries, request failed
All retry attempts failed due to network errors.
fix
Check network connectivity and server availability; consider increasing retries or using exponential backoff.
Upgrade
Version history
2.7.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
18
Resources
za-fetch-api — npm install za-fetch-api · libregistry