{"id":49605,"library":"universal-fetch","title":"universal-fetch","description":"Universal WHATWG Fetch API polyfill for Node.js and browsers including IE8. Version 1.0.0 (latest). This package adds a global `fetch` function, built on top of GitHub's fetch polyfill. It requires an ES6 Promise polyfill (e.g., es6-promise) and does not bundle one. It is designed for use with bundlers like Webpack or Browserify. Compared to isomorphic-fetch, it adds IE8 support but has been largely superseded by native fetch and modern polyfills like whatwg-fetch.","status":"abandoned","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Pitzcarraldo/universal-fetch","tags":["javascript"],"install":[{"cmd":"npm install universal-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add universal-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add universal-fetch","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"universal-fetch sets fetch as a global side effect; it does not export fetch. You must import the package for its side effects only. Also requires an ES6 Promise polyfill.","wrong":"import fetch from 'universal-fetch';","symbol":"global fetch","correct":"import 'es6-promise/auto'; import 'universal-fetch';"},{"note":"Using require('universal-fetch') returns an empty object; fetch is set globally. The Promise polyfill must be polyfilled before loading universal-fetch.","wrong":"const fetch = require('universal-fetch');","symbol":"CommonJS require","correct":"require('es6-promise').polyfill(); require('universal-fetch');"},{"note":"This package does not ship TypeScript definitions. Add '@types/whatwg-fetch' to your devDependencies or manually declare the global fetch function.","wrong":"import { fetch } from 'universal-fetch';","symbol":"TypeScript types","correct":"No types provided; use @types/whatwg-fetch or declare global fetch"}],"quickstart":{"code":"// Install: npm install universal-fetch es6-promise\n// Then in your entry file:\nrequire('es6-promise').polyfill();\nrequire('universal-fetch');\n\nfetch('https://jsonplaceholder.typicode.com/posts/1')\n  .then(function(response) {\n    if (!response.ok) throw new Error('Network response was not ok');\n    return response.json();\n  })\n  .then(function(post) {\n    console.log(post.title);\n  })\n  .catch(function(error) {\n    console.error('Fetch error:', error);\n  });","lang":"javascript","description":"Shows global fetch usage after requiring both es6-promise polyfill and universal-fetch side-effect import."},"warnings":[{"fix":"Replace with whatwg-fetch for browsers and native fetch in Node 18+.","message":"Package is unmaintained (last update 2016). Use native fetch or whatwg-fetch instead.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install es6-promise and call polyfill() before loading universal-fetch.","message":"Requires a separate ES6 Promise polyfill; not bundled.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use side-effect import only: import 'universal-fetch'; then use global fetch.","message":"Does not export fetch; it sets fetch as a global. Direct import or require returns an empty object.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install @types/whatwg-fetch or declare 'declare var fetch: typeof globalThis.fetch;'","message":"No TypeScript types included. TypeScript builds will error on global fetch without type declarations.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.0':16 'add':20,65 'api':7 'browser':12 'browserifi':58 'built':25 'bundl':46 'bundler':54 'compar':59 'design':50 'e.g':39 'es6':36,41 'es6-promise':40 'fetch':3,6,23,31,63,75,82 'function':24 'github':29 'global':22 'ie8':14,66 'includ':13 'isomorph':62 'isomorphic-fetch':61 'javascript':83 'larg':71 'latest':17 'like':55,79 'modern':77 'nativ':74 'node.js':10 'one':47 'packag':19 'polyfil':8,32,38,78 'promis':37,42 'requir':34 'supersed':72 'support':67 'top':27 'univers':2,4 'universal-fetch':1 'use':52 'version':15 'webpack':56 'whatwg':5,81 'whatwg-fetch':80","created_at":"2026-06-07T17:02:38.194255+00:00","updated_at":"2026-06-07T17:02:38.194255+00:00","problems":[{"fix":"Ensure es6-promise polyfill is called before importing universal-fetch, and that the side-effect import is present.","cause":"universal-fetch not loaded, or loaded before Promise polyfill.","error":"fetch is not defined"},{"fix":"Run: npm install universal-fetch es6-promise","cause":"Package not installed, or typo in import path.","error":"Cannot find module 'universal-fetch'"},{"fix":"Check the URL and CORS headers. Ensure universal-fetch is loaded as polyfill.","cause":"CORS issue or network error; or fetch not supported in older browser without polyfill.","error":"Uncaught TypeError: Failed to fetch"}],"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/Pitzcarraldo/universal-fetch/issues","github":"https://github.com/Pitzcarraldo/universal-fetch","docs":null,"changelog":null,"pypi":null,"npm":"universal-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["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}}