{"id":17854073,"url":"https://github.com/rednexie/node-fetch-patch","last_synced_at":"2026-04-13T17:32:19.326Z","repository":{"id":207035364,"uuid":"718200179","full_name":"Rednexie/node-fetch-patch","owner":"Rednexie","description":"a nodejs fetch polyfill/patch, ensures the availability across environments and versions. ","archived":false,"fork":false,"pushed_at":"2024-02-02T23:10:20.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T17:21:54.641Z","etag":null,"topics":["fetch","fetch-api","fetch-patch","fetch-polyfill","js","node","node-fetch","node-fetch-polyfill","node-js","nodejs","npm","patch","polyfill"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rednexie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-11-13T15:36:50.000Z","updated_at":"2024-02-02T23:12:43.000Z","dependencies_parsed_at":"2023-11-13T19:56:16.481Z","dependency_job_id":"b42b2f28-a5ed-4639-a803-4b018bbcab22","html_url":"https://github.com/Rednexie/node-fetch-patch","commit_stats":null,"previous_names":["rednexie/node-fetch-patch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Rednexie/node-fetch-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rednexie%2Fnode-fetch-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rednexie%2Fnode-fetch-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rednexie%2Fnode-fetch-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rednexie%2Fnode-fetch-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rednexie","download_url":"https://codeload.github.com/Rednexie/node-fetch-patch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rednexie%2Fnode-fetch-patch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267616728,"owners_count":24116162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fetch","fetch-api","fetch-patch","fetch-polyfill","js","node","node-fetch","node-fetch-polyfill","node-js","nodejs","npm","patch","polyfill"],"created_at":"2024-10-28T00:41:44.284Z","updated_at":"2026-04-13T17:32:14.275Z","avatar_url":"https://github.com/Rednexie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-fetch-patch\na nodejs fetch polyfill/patch, ensures the availability across environments and versions. \n\n# How does it work?\nimport the \u003ca target=\"_blank\" href=\"https://raw.githubusercontent.com/Rednexie/node-fetch-patch/main/node-fetch-patch.js\" download=\"node-fetch-patch.js\"\u003emain file\u003c/a\u003e (for v10.0 - 20.8.1)\n```js\nconst fetch = require('./node-fetch-patch');\n```\nor the [other one](https://raw.githubusercontent.com/Rednexie/node-fetch-patch/main/node-fetch-patch-all.js) to use with nodejs versions below 10 (since async import is not available)\n```js\nconst fetch = require('./node-fetch-patch-all');\n```\n\n\n\u003cbr\u003e\n\n\n\n- Firstly, the module checks if nodejs native fetch api (built-in) is supported.\n- If not, it checks for a node-fetch installation(specifically below 2.6.1), and tries to do a CommonJS require.\n- If it doesn't work, tries to import node-fetch with async import function. This works for the verions above 2.6.1.\n- If any of those work, it installs node-fetch using node package manager, then restarts the script/console.\n\n# How do I know where 'fetch' was imported from?\nnode-fetch-patch will add a some properties to let you know this:\n- environment variable: `process.env.PATCHTYPE`\n- global variable: `global.patchType`\n- along with a property: `fetch.patchType`\n\n\nFor example, if the fetch function was imported from nodejs native fetch api:\n\n```js\n\u003e console.log(fetch)\n[AsyncFunction: fetch] { patchType: 0 }\n\n\u003e console.log(global.patchType)\n0\n\n\u003e console.log(process.env.PATCHTYPE)\n'0'\n```\n\nFrom node-fetch versions below 2.6.1 using CommonJS require:\n```js\n\u003e console.log(fetch)\n[AsyncFunction: fetch] { patchType: 2 }\n\n\u003e console.log(global.patchType)\n2\n\n\u003e console.log(process.env.PATCHTYPE)\n'2'\n```\n\nFrom node-fetch versions above 2.6.1 using async import (unavailable in `node-fetch-patch-all.js`):\n```js\n\u003e console.log(fetch)\n[AsyncFunction: fetch] { patchType: 3 }\n\n\u003e console.log(global.patchType)\n3\n\n\u003e console.log(process.env.PATCHTYPE)\n'3'\n```\nif no fetch function found (this means node-fetch-patch is installing it and will restart the main process or node console):\n```js\n\u003e console.log(fetch)\n{ patchType: undefined }\n\n\u003e console.log(global.patchType)\nundefined\n\n\u003e console.log(process.env.PATCHTYPE)\nundefined\n```\nOr if node-fetch-patch couldn't export the fetch function (mostly because of an error):\n```js\n\u003e console.log(fetch)\n{ patchType: null }\n\n\u003e console.log(global.patchType)\nnull\n\n\u003e console.log(process.env.PATCHTYPE)\n'null'\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frednexie%2Fnode-fetch-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frednexie%2Fnode-fetch-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frednexie%2Fnode-fetch-patch/lists"}