{"id":47491,"library":"enterprise-fetch","title":"enterprise-fetch","description":"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.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/neilflatley/enterprise-fetch","tags":["javascript","fetch","retry","exponential","backoff","factor","timeout","abort","typescript"],"install":[{"cmd":"npm install enterprise-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add enterprise-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add enterprise-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Polyfill for fetch in Node.js < 18; not needed in modern Node or browser","package":"node-fetch","optional":true}],"imports":[{"note":"Default export, not named. For CJS: const enterpriseFetch = require('enterprise-fetch').","wrong":"import { enterpriseFetch } from 'enterprise-fetch'","symbol":"enterpriseFetch","correct":"import enterpriseFetch from 'enterprise-fetch'"},{"note":"Named export for custom fetch instances. ESM-only for named imports; CJS uses destructuring from require().","wrong":"const createFetch = require('enterprise-fetch').createFetch","symbol":"createFetch","correct":"import { createFetch } from 'enterprise-fetch'"},{"note":"Type import for init options including timeout and retry. Only available with TypeScript.","wrong":"","symbol":"FetchInit","correct":"import type { FetchInit } from 'enterprise-fetch'"}],"quickstart":{"code":"import enterpriseFetch from 'enterprise-fetch';\n\nasync function main() {\n  const res = await enterpriseFetch('https://httpbin.org/json', {\n    timeout: 5000,\n    retry: {\n      retries: 3,\n      minTimeout: 400,\n      factor: 2,\n    },\n  });\n  const data = await res.json();\n  console.log(data);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows default import with timeout and custom retry policy using async/await."},"warnings":[{"fix":"Always provide timeout in milliseconds, use 0 or undefined to disable.","message":"The 'timeout' option in FetchInit expects milliseconds. Passing undefined or 0 disables timeout.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Provide full retry config or omit to use defaults.","message":"The 'retry' option expects object with 'retries', 'minTimeout', 'factor', and optionally 'maxTimeout'. Missing fields fall back to defaults.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update doRetry to new signature: (attempt, res, { url, options }) => boolean","message":"In v2.x the 'doRetry' callback signature changed to (attempt, res, { url, options }). In v1.x it was (attempt, error, response).","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Do not depend on 'abort' event; handle timeout via catch block checking 'name' property.","message":"The 'abort' event from AbortController may not fire in all environments; timeout relies on signal.aborted check.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a fetch polyfill for older browsers or import 'node-fetch' for Node < 18.","message":"In browser, if native fetch is not available (old browsers), you must provide a polyfill like 'whatwg-fetch'.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'abort':69 'abortcontrol':19 'add':8 'backoff':15,66 'browser':28 'built':46 'built-in':45 'bundl':35 'callback':58 'cjs':34 'configur':48 'current':25 'custom':60 'definit':39 'differenti':40 'doretri':57 'enterpris':2,9 'enterprise-fetch':1 'esm':32 'exponenti':14,65 'factor':52,67 'featur':10 'fetch':3,5,43,63 'includ':37 'javascript':62 'like':11 'logic':61 'maxtimeout':54 'mintimeout':51 'node.js':30 'plain':42 'plus':55 'polici':13 'proxi':22 'request':16,21 'retri':12,49,64 'ship':31 'support':26 'timeout':17,68 'typescript':38,70 'v2.0.2':23 'via':18 'wrapper':6","created_at":"2026-06-07T16:51:47.341847+00:00","updated_at":"2026-06-07T16:51:47.341847+00:00","problems":[{"fix":"Install 'node-fetch' and add 'import fetch from 'node-fetch'; global.fetch = fetch;' or upgrade Node to >=18.","cause":"Running in Node.js < 18 without fetch polyfill.","error":"TypeError: fetch is not a function"},{"fix":"Ensure 'enterprise-fetch' is installed and use 'import enterpriseFetch from 'enterprise-fetch'; for default import.","cause":"Missing TypeScript types or wrong import path.","error":"Cannot find module 'enterprise-fetch' or its corresponding type declarations"},{"fix":"Update doRetry to match new signature: (attempt, res, { url, options }) => boolean","cause":"Wrong signature in v2: old code passes (attempt, error, response) but new expects (attempt, res, { url, options }).","error":"The 'doRetry' callback is not a function"},{"fix":"Increase timeout or ensure server responds within timeout window.","cause":"Request timed out due to default timeout (60s) or explicit timeout.","error":"AbortError: The operation was aborted"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/neilflatley/enterprise-fetch#readme","github":"https://github.com/neilflatley/enterprise-fetch","docs":null,"changelog":null,"pypi":null,"npm":"enterprise-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}