{"id":48565,"library":"modelproxy-engine-fetch","title":"modelproxy-engine-fetch","description":"A fetch-based engine for the modelproxy library, enabling HTTP requests via the Fetch API. Version 3.0.31 is current. This engine provides timeout, cache (in-memory with optional expiration), and reload features. It is designed to work with the modelproxy proxy system, allowing middleware-like request/response interception. Compared to other engines like AxiosEngine, this one leverages the built-in fetch, reducing dependencies. Release cadence is irregular; updates focus on bug fixes and compatibility.","status":"active","version":"3.0.31","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install modelproxy-engine-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add modelproxy-engine-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add modelproxy-engine-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the engine integrates with modelproxy's Proxy and engine system.","package":"modelproxy","optional":true}],"imports":[{"note":"Default CommonJS require is incorrect because the package exports a named export. Use ESM import or destructure require.","wrong":"const FetchEngine = require('modelproxy-engine-fetch')","symbol":"FetchEngine","correct":"import { FetchEngine } from 'modelproxy-engine-fetch'"},{"note":"TypeScript users can import only the type for type-checking without runtime import.","wrong":null,"symbol":"type FetchEngine","correct":"import type { FetchEngine } from 'modelproxy-engine-fetch'"},{"note":"Constructor usage is straightforward; ensure to call init() after instantiation.","wrong":"const engine = new (require('modelproxy-engine-fetch').FetchEngine)()","symbol":"Instance","correct":"import { FetchEngine } from 'modelproxy-engine-fetch'; const engine = new FetchEngine()"}],"quickstart":{"code":"import { FetchEngine } from 'modelproxy-engine-fetch';\nimport { Proxy } from 'modelproxy';\n\nconst fetchEngine = new FetchEngine();\nfetchEngine.init();\n\n// Add middleware to check status and data code\nfetchEngine.use(async (ctx, next) => {\n  if (ctx.result.status !== 200) {\n    throw new Error(ctx.result.statusText);\n  }\n  ctx.result = await ctx.result.clone();\n  const serData = await ctx.result.json();\n  if (serData.code !== 200) {\n    throw new Error(serData.message);\n  }\n  await next();\n});\n\nconst proxy = new Proxy();\nproxy.addEngines({ react: fetchEngine });\n\n// Example usage: proxy.execute('someKey', { ... })\n","lang":"typescript","description":"Initializes a FetchEngine, adds a middleware to validate HTTP status and response data code, then registers it with modelproxy Proxy."},"warnings":[{"fix":"Use ctx.result.clone() before calling .json() or .text() on the response.","message":"Fetch result body can only be read once. Must clone the response before reading.","severity":"gotcha","affected_versions":"all"},{"fix":"Call await next() in each middleware to continue the pipeline.","message":"Middleware exec order: the engine uses a middleware pipeline. If next() is not called, subsequent middleware won't execute.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider migrating to other engines like modelproxy-engine-axios if active maintenance is needed.","message":"The release cadence is irregular; no active development since 2022.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Use an external caching layer if persistence is required.","message":"Cache is in-memory only and non-persistent. Setting expire does not persist across requests.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.0.31':22 'allow':49 'api':20 'axiosengin':60 'base':8 'bug':78 'built':66 'built-in':65 'cach':29 'cadenc':72 'compar':55 'compat':81 'current':24 'depend':70 'design':41 'enabl':14 'engin':3,9,26,58 'expir':35 'featur':38 'fetch':4,7,19,68 'fetch-bas':6 'fix':79 'focus':76 'http':15 'in-memori':30 'intercept':54 'irregular':74 'javascript':82 'leverag':63 'librari':13 'like':52,59 'memori':32 'middlewar':51 'middleware-lik':50 'modelproxi':2,12,46 'modelproxy-engine-fetch':1 'one':62 'option':34 'provid':27 'proxi':47 'reduc':69 'releas':71 'reload':37 'request':16 'request/response':53 'system':48 'timeout':28 'typescript':83 'updat':75 'version':21 'via':17 'work':43","created_at":"2026-06-07T16:57:18.280157+00:00","updated_at":"2026-06-07T16:57:18.280157+00:00","problems":[{"fix":"Use ctx.result = await ctx.result.clone(); before reading.","cause":"Calling response.json() twice without cloning the response.","error":"TypeError: Body already read"},{"fix":"Ensure middleware does not replace ctx.result prematurely; clone and preserve Response type.","cause":"Middleware may have set ctx.result to something else (e.g., parsed JSON) before next middleware runs.","error":"TypeError: ctx.result is not a Response"},{"fix":"Increase timeout via settings: new FetchEngine({ settings: { timeout: 10000 } })","cause":"Request took longer than default timeout.","error":"Error: Timeout of 5000ms exceeded"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"modelproxy-engine-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}