{"id":47637,"library":"fetch-ponyfill","title":"fetch-ponyfill","description":"A WHATWG fetch ponyfill (does not overwrite native fetch) that wraps github/fetch for the browser and delegates to node-fetch in Node.js. Current version 7.1.0. Ships TypeScript types. Ideal for environments where you need fetch without side effects or globals. Returns a setup function that yields fetch, Request, Response, Headers. Supports Promise and XMLHttpRequest options. Maintained, with regular releases.","status":"active","version":"7.1.0","language":"javascript","source_language":"en","source_url":"git://github.com/qubyte/fetch-ponyfill","tags":["javascript","fetch","ponyfill","typescript"],"install":[{"cmd":"npm install fetch-ponyfill","lang":"bash","label":"npm"},{"cmd":"yarn add fetch-ponyfill","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetch-ponyfill","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"used in Node.js environment for actual fetch implementation","package":"node-fetch","optional":true}],"imports":[{"note":"fetch-ponyfill exports a factory function, not the fetch object directly. You must call it to get fetch.","wrong":"import {fetch} from 'fetch-ponyfill';","symbol":"fetchPonyfill","correct":"import fetchPonyfill from 'fetch-ponyfill'; const {fetch} = fetchPonyfill();"},{"note":"CommonJS usage: require('fetch-ponyfill') gives the factory function, not an object with fetch.","wrong":"const fetchPonyfill = require('fetch-ponyfill'); const fetch = fetchPonyfill.fetch;","symbol":"fetch, Request, Response, Headers","correct":"const {fetch, Request, Response, Headers} = require('fetch-ponyfill')(options);"},{"note":"Types bundled; works well with TypeScript. No special import needed for types.","symbol":"TypeScript types","correct":"import fetchPonyfill from 'fetch-ponyfill'; const {fetch} = fetchPonyfill();"}],"quickstart":{"code":"import fetchPonyfill from 'fetch-ponyfill';\n\nconst {fetch, Request, Response, Headers} = fetchPonyfill({\n  Promise: globalThis.Promise,\n});\n\nasync function main() {\n  const response = await fetch('https://api.example.com/data');\n  const data = await response.json();\n  console.log(data);\n}\n\nmain();\n","lang":"typescript","description":"Demonstrates importing the factory, calling it with options, and using the fetch function for an HTTP GET request."},"warnings":[{"fix":"Ensure Node version >=12. Use the factory function to obtain Request, Response, and Headers.","message":"Version 7.0.0 dropped support for Node < 12 and removed deprecated options like 'Request' and 'Headers' as direct exports.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Always call fetchPonyfill() (with or without options) before destructuring.","message":"The exported function is a factory; forgetting to call it will yield undefined for fetch.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Remove XMLHttpRequest option; rely on built-in fetch or provide it only for Firefox OS.","message":"XMLHttpRequest option is deprecated in browser environment; native fetch is preferred.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Use `import fetchPonyfill from 'fetch-ponyfill'` instead of `import { fetch } from 'fetch-ponyfill'`.","message":"When using webpack, ensure you import the default export first, then call it; direct named imports from the package do not exist.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'7.1.0':29 'browser':18 'current':27 'deleg':20 'effect':42 'environ':35 'fetch':2,6,12,24,39,51,65 'fetch-ponyfil':1 'function':48 'github/fetch':15 'global':44 'header':54 'ideal':33 'javascript':64 'maintain':60 'nativ':11 'need':38 'node':23 'node-fetch':22 'node.js':26 'option':59 'overwrit':10 'ponyfil':3,7,66 'promis':56 'regular':62 'releas':63 'request':52 'respons':53 'return':45 'setup':47 'ship':30 'side':41 'support':55 'type':32 'typescript':31,67 'version':28 'whatwg':5 'without':40 'wrap':14 'xmlhttprequest':58 'yield':50","created_at":"2026-06-07T16:52:32.112830+00:00","updated_at":"2026-06-07T16:52:32.112830+00:00","problems":[{"fix":"Use default import: import fetchPonyfill from 'fetch-ponyfill'; then call it.","cause":"Using named import incorrectly (e.g., import { fetch } from 'fetch-ponyfill')","error":"TypeError: fetchPonyfill is not a function"},{"fix":"Install node-fetch: npm install node-fetch (or it is automatically a dependency).","cause":"The package requires node-fetch in Node.js but it might not be installed.","error":"Cannot find module 'node-fetch'"},{"fix":"Correct: const {fetch} = fetchPonyfill(); not const {fetch} = require('fetch-ponyfill');","cause":"Using the factory but destructuring without calling it.","error":"fetch is not defined"}],"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/qubyte/fetch-ponyfill#readme","github":"git://github.com/qubyte/fetch-ponyfill","docs":null,"changelog":null,"pypi":null,"npm":"fetch-ponyfill","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}}