Registry / devops / fetch-helper-x

fetch-helper-x

JSON →
library0.1.8jsnpmunverified

Minimal Fetch API utility library for Node.js >=20 and browsers. Provides timeout and retry wrappers around the native fetch. Current version 0.1.8, pre-v1 release with infrequent updates. Differentiates by being TypeScript-first, zero-dependency, and supporting both Node.js built-in fetch (no polyfill needed) and browser environments via the same API. No dependency on node-fetch or undici.

npm install fetch-helper-x
INSTALL
IMPORT
SIG · FETCH-HELPER-X
F
fetch-helper-x
devopsjavascriptv0.1.8
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.

timeoutFetch
import { timeoutFetch } from 'fetch-helper-x'
import timeoutFetch from 'fetch-helper-x'
Default export does not exist; named export only. ESM-only package, CJS require() will fail.
retryFetch
import { retryFetch } from 'fetch-helper-x'
const { retryFetch } = require('fetch-helper-x')
This package is ESM-only (node>=20), do not use require(). TypeScript types included.
TimeoutFetchOptions
import type { TimeoutFetchOptions } from 'fetch-helper-x'
import { TimeoutFetchOptions } from 'fetch-helper-x'
Use type import to avoid runtime inclusion in TypeScript.

Demonstrates timeoutFetch and retryFetch with JSON parsing, and the importance of canceling the response body to prevent memory leaks.

import { timeoutFetch, retryFetch } from 'fetch-helper-x'; const url = 'https://api.example.com/data'; // Simple timeout fetch const res1 = await timeoutFetch(url, { requestTimeout: 5000 }); const data1 = await res1.json(); console.log(data1); // Retry with exponential backoff const res2 = await retryFetch(url, { retries: 3, retryDelay: 1000 }); const data2 = await res2.json(); console.log(data2); // Remember to cancel body to avoid hanging await res2.cancelBody();
Debug
Known issues
gotchaAfter reading the response body (e.g., .text() or .json()), the underlying AbortController and timers are not automatically cleaned up; you must call .cancelBody() to avoid resource leaks.
fix
Always call `await response.cancelBody()` after processing the response body, or handle the response as a stream.
affects: >=0.1.0
breakingPackage is ESM-only and requires Node.js >=20. Using require() or older Node versions will throw an error.
fix
Use `import` syntax and upgrade Node.js to >=20.
affects: >=0.1.0
deprecatedVersion 0.x is considered pre-release; the API may change without major semver bump.
fix
Pin to exact version or be prepared to adapt changes on minor/patch updates.
affects: >=0.1.0
gotchaThe `requestTimeout` option in timeoutFetch does not cancel the request; only the response waiting time is limited. The fetch operation continues unless AbortController signal is used, but this library does not expose that signal.
fix
If you need to fully abort the request, combine with AbortController manually.
affects: >=0.1.0
Errors
Common errors & fixes
SyntaxError: The requested module 'fetch-helper-x' does not provide an export named 'timeoutFetch'
Using default import instead of named import.
fix
import { timeoutFetch } from 'fetch-helper-x'
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() instead of import.
fix
Use `import('fetch-helper-x')` dynamic import or switch to ESM syntax.
fetch is not defined (in Node <20)
Native fetch not available in Node <20, and this library does not polyfill.
fix
Upgrade Node to >=20 or use a fetch polyfill like undici.
Upgrade
Version history
0.1.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fetch-helper-x — npm install fetch-helper-x · libregistry