Registry / devops / enterprise-fetch

enterprise-fetch

JSON →
library2.0.2jsnpmunverified

A fetch wrapper that adds enterprise features like retry policy (exponential backoff), request timeout via AbortController, and request proxy. v2.0.2 is current, supports both browser and Node.js, ships ESM and CJS bundles, and includes TypeScript definitions. Differentiated from plain fetch by built-in configurable retry with minTimeout, factor, and maxTimeout, plus a doRetry callback for custom logic.

npm install enterprise-fetch
INSTALL
IMPORT
SIG · ENTERPRISE-FETCH
E
enterprise-fetch
devopsjavascriptv2.0.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.

enterpriseFetch
import enterpriseFetch from 'enterprise-fetch'
import { enterpriseFetch } from 'enterprise-fetch'
Default export, not named. For CJS: const enterpriseFetch = require('enterprise-fetch').
createFetch
import { createFetch } from 'enterprise-fetch'
const createFetch = require('enterprise-fetch').createFetch
Named export for custom fetch instances. ESM-only for named imports; CJS uses destructuring from require().
FetchInit
import type { FetchInit } from 'enterprise-fetch'
Type import for init options including timeout and retry. Only available with TypeScript.

Shows default import with timeout and custom retry policy using async/await.

import enterpriseFetch from 'enterprise-fetch'; async function main() { const res = await enterpriseFetch('https://httpbin.org/json', { timeout: 5000, retry: { retries: 3, minTimeout: 400, factor: 2, }, }); const data = await res.json(); console.log(data); } main().catch(console.error);
Debug
Known issues
gotchaThe 'timeout' option in FetchInit expects milliseconds. Passing undefined or 0 disables timeout.
fix
Always provide timeout in milliseconds, use 0 or undefined to disable.
affects: >=1.0.0
gotchaThe 'retry' option expects object with 'retries', 'minTimeout', 'factor', and optionally 'maxTimeout'. Missing fields fall back to defaults.
fix
Provide full retry config or omit to use defaults.
affects: >=1.0.0
breakingIn v2.x the 'doRetry' callback signature changed to (attempt, res, { url, options }). In v1.x it was (attempt, error, response).
fix
Update doRetry to new signature: (attempt, res, { url, options }) => boolean
affects: >=2.0.0
gotchaThe 'abort' event from AbortController may not fire in all environments; timeout relies on signal.aborted check.
fix
Do not depend on 'abort' event; handle timeout via catch block checking 'name' property.
affects: >=1.0.0
gotchaIn browser, if native fetch is not available (old browsers), you must provide a polyfill like 'whatwg-fetch'.
fix
Use a fetch polyfill for older browsers or import 'node-fetch' for Node < 18.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: fetch is not a function
Running in Node.js < 18 without fetch polyfill.
fix
Install 'node-fetch' and add 'import fetch from 'node-fetch'; global.fetch = fetch;' or upgrade Node to >=18.
Cannot find module 'enterprise-fetch' or its corresponding type declarations
Missing TypeScript types or wrong import path.
fix
Ensure 'enterprise-fetch' is installed and use 'import enterpriseFetch from 'enterprise-fetch'; for default import.
The 'doRetry' callback is not a function
Wrong signature in v2: old code passes (attempt, error, response) but new expects (attempt, res, { url, options }).
fix
Update doRetry to match new signature: (attempt, res, { url, options }) => boolean
AbortError: The operation was aborted
Request timed out due to default timeout (60s) or explicit timeout.
fix
Increase timeout or ensure server responds within timeout window.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
node-fetchoptionalPolyfill for fetch in Node.js < 18; not needed in modern Node or browser
Agent activity
13 hits · last 30 days
node
10
Amazon
1
Resources
enterprise-fetch — npm install enterprise-fetch · libregistry