{"_id":"@merceas/cross-fetch","_rev":"2-6ed49d9f7f6c0980ba08ebf11bc0451c","name":"@merceas/cross-fetch","dist-tags":{"latest":"3.1.12"},"versions":{"3.1.9":{"name":"@merceas/cross-fetch","version":"3.1.9","keywords":["fetch","http","url","promise","async","await","isomorphic","universal","node","react","native","browser","ponyfill","whatwg","xhr","ajax"],"author":{"name":"Leonardo Quixada","email":"lquixada@gmail.com"},"license":"MIT","_id":"@merceas/cross-fetch@3.1.9","maintainers":[{"name":"merceas","email":"merceas-ij8cau@web-library.net"}],"homepage":"https://github.com/lquixada/cross-fetch","bugs":{"url":"https://github.com/lquixada/cross-fetch/issues"},"nyc":{"temp-dir":".reports/.coverage"},"dist":{"shasum":"dae7f98afbdc4ef9d232ad1513c97ff4a7c7036e","tarball":"https://registry.npmjs.org/@merceas/cross-fetch/-/cross-fetch-3.1.9.tgz","fileCount":13,"integrity":"sha512-5Salu2vnpYqAt7QMZ43MgkQJP3H1QvWupN1oWaXbBaJrgMVrOw5PpeAAkdTsl6mzY8mgMW9Lo0V91rmz+d7CQg==","signatures":[{"sig":"MEUCIQDDfdaGSVmDjzhuOUwT6klK2kzEI9gBKjX/rhyfDV8NvAIgeDTe62nz4f+VNsY51yyI6UjjPEJCY70D3HY7gHD3Oto=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76763},"main":"dist/node-ponyfill.js","mocha":{"require":["chai/register-expect","chai/register-assert"],"check-leaks":true},"types":"index.d.ts","config":{"commitizen":{"path":"cz-conventional-changelog"}},"browser":"dist/browser-ponyfill.js","gitHead":"25241c0e5a0546b26bb7fc9d5a2bd72adf7505fe","scripts":{"commit":"cz","prepare":"husky install","prepublishOnly":"rimraf dist && make build"},"_npmUser":{"name":"merceas","email":"merceas-ij8cau@web-library.net"},"standard":{"env":["mocha","browser"],"ignore":["/dist/","bundle.js","test.js","test.*.js","api.spec.js","*.ts"],"globals":["expect","assert","chai"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"repository":{"url":"git+https://github.com/lquixada/cross-fetch.git","type":"git"},"_npmVersion":"11.11.0","description":"Universal WHATWG Fetch API for Node, Browsers and React Native","directories":{},"lint-staged":{"*.js":["standard --fix"]},"_nodeVersion":"24.14.1","dependencies":{"node-fetch":"^2.6.12"},"react-native":"dist/react-native-ponyfill.js","_hasShrinkwrap":false,"devDependencies":{"nyc":"15.1.0","chai":"4.3.4","nock":"13.1.3","husky":"6.0.0","mocha":"8.3.2","yargs":"16.2.0","rimraf":"3.0.2","rollup":"2.58.0","semver":"7.3.5","codecov":"3.8.3","express":"4.17.1","webpack":"5.82.1","open-cli":"6.0.1","standard":"16.0.4","commitizen":"4.2.4","typescript":"4.4.4","@types/chai":"4.2.22","@types/node":"14.14.37","body-parser":"1.19.0","lint-staged":"10.5.4","serve-index":"1.9.1","webpack-cli":"4.9.0","@types/mocha":"8.2.2","whatwg-fetch":"3.0.0","@commitlint/cli":"12.0.1","standard-version":"9.3.1","rollup-plugin-copy":"3.4.0","rollup-plugin-terser":"7.0.2","mocha-headless-chrome":"4.0.0","cz-conventional-changelog":"3.3.0","@commitlint/config-conventional":"12.0.1"},"_npmOperationalInternal":{"tmp":"tmp/cross-fetch_3.1.9_1782008434813_0.009791386940876334","host":"s3://npm-registry-packages-npm-production"}},"3.1.12":{"name":"@merceas/cross-fetch","version":"3.1.12","description":"Universal WHATWG Fetch API for Node, Browsers and React Native","homepage":"https://github.com/lquixada/cross-fetch","main":"dist/node-ponyfill.js","browser":"dist/browser-ponyfill.js","react-native":"dist/react-native-ponyfill.js","types":"index.d.ts","scripts":{"commit":"cz","prepare":"husky install","prepublishOnly":"rimraf dist && make build"},"lint-staged":{"*.js":["standard --fix"]},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"standard":{"env":["mocha","browser"],"globals":["expect","assert","chai"],"ignore":["/dist/","bundle.js","test.js","test.*.js","api.spec.js","*.ts"]},"mocha":{"require":["chai/register-expect","chai/register-assert"],"check-leaks":true},"nyc":{"temp-dir":".reports/.coverage"},"commitlint":{"extends":["@commitlint/config-conventional"]},"repository":{"type":"git","url":"git+https://github.com/lquixada/cross-fetch.git"},"author":{"name":"Leonardo Quixada","email":"lquixada@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/lquixada/cross-fetch/issues"},"dependencies":{"node-fetch":"^2.6.12"},"devDependencies":{"@commitlint/cli":"12.0.1","@commitlint/config-conventional":"12.0.1","@types/chai":"4.2.22","@types/mocha":"8.2.2","@types/node":"14.14.37","body-parser":"1.19.0","chai":"4.3.4","codecov":"3.8.3","commitizen":"4.2.4","cz-conventional-changelog":"3.3.0","express":"4.17.1","husky":"6.0.0","lint-staged":"10.5.4","mocha":"8.3.2","mocha-headless-chrome":"4.0.0","nock":"13.1.3","nyc":"15.1.0","open-cli":"6.0.1","rimraf":"3.0.2","rollup":"2.58.0","rollup-plugin-copy":"3.4.0","rollup-plugin-terser":"7.0.2","semver":"7.3.5","serve-index":"1.9.1","standard":"16.0.4","standard-version":"9.3.1","typescript":"4.4.4","webpack":"5.82.1","webpack-cli":"4.9.0","whatwg-fetch":"3.0.0","yargs":"16.2.0"},"keywords":["fetch","http","url","promise","async","await","isomorphic","universal","node","react","native","browser","ponyfill","whatwg","xhr","ajax"],"gitHead":"9c5b6732196f1e76f350995deb9c568793aa4c9c","_id":"@merceas/cross-fetch@3.1.12","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-g9OiIa1Tyf1RS6I6igC7JFOSenkMR3APZt3yGWFmxIpK2UDUwiehe9vOmG/n4h6DBn69rtR4ERAaIynUnNbgPA==","shasum":"c551eeb1e01d4a5c1bd84fa777ff1fb4a42ad79e","tarball":"https://registry.npmjs.org/@merceas/cross-fetch/-/cross-fetch-3.1.12.tgz","fileCount":13,"unpackedSize":170931,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDEdYNoLi0CohIeKpVWGbOH86ZqRSwsAgifCHdumYkeQAiAL+ubRaFrAgy2zb4bSMBwpYNRGLBHUpdQ0g3DRSdTSoA=="}]},"_npmUser":{"name":"merceas","email":"merceas-ij8cau@web-library.net"},"directories":{},"maintainers":[{"name":"merceas","email":"merceas-ij8cau@web-library.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cross-fetch_3.1.12_1782121010647_0.5970940850125552"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-21T02:20:34.667Z","modified":"2026-06-22T09:36:50.910Z","3.1.9":"2026-06-21T02:20:34.969Z","3.1.12":"2026-06-22T09:36:50.781Z"},"bugs":{"url":"https://github.com/lquixada/cross-fetch/issues"},"author":{"name":"Leonardo Quixada","email":"lquixada@gmail.com"},"license":"MIT","homepage":"https://github.com/lquixada/cross-fetch","keywords":["fetch","http","url","promise","async","await","isomorphic","universal","node","react","native","browser","ponyfill","whatwg","xhr","ajax"],"repository":{"type":"git","url":"git+https://github.com/lquixada/cross-fetch.git"},"description":"Universal WHATWG Fetch API for Node, Browsers and React Native","maintainers":[{"name":"merceas","email":"merceas-ij8cau@web-library.net"}],"readme":"cross-fetch<br>\n[![NPM Version](https://img.shields.io/npm/v/cross-fetch.svg?branch=main)](https://www.npmjs.com/package/cross-fetch)\n[![Downloads Per Week](https://img.shields.io/npm/dw/cross-fetch.svg?color=blue)](https://www.npmjs.com/package/cross-fetch)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![CI](https://github.com/lquixada/cross-fetch/actions/workflows/ci.yml/badge.svg)](https://github.com/lquixada/cross-fetch/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/lquixada/cross-fetch/branch/main/graph/badge.svg)](https://codecov.io/gh/lquixada/cross-fetch)\n================\n\nUniversal WHATWG Fetch API for Node, Browsers and React Native. The scenario that cross-fetch really shines is when the same JavaScript codebase needs to run on different platforms.\n\n- **Platform agnostic**: browsers, Node or React Native\n- **Optional polyfill**: it's up to you if something is going to be added to the global object or not\n- **Simple interface**: no instantiation, no configuration and no extra dependency\n- **WHATWG compliant**: it works the same way wherever your code runs\n- **TypeScript support**: better development experience with types.\n\n\n* * *\n\n## Table of Contents\n\n-   [Install](#install)\n-   [Usage](#usage)\n-   [Demo & API](#demo--api)\n-   [FAQ](#faq)\n-   [Thanks](#thanks)\n-   [License](#license)\n-   [Author](#author)\n\n* * *\n\n## Install\n\n```sh\nnpm install --save cross-fetch\n```\n\nAs a [ponyfill](https://github.com/sindresorhus/ponyfill):\n\n```javascript\n// Using ES6 modules with Babel or TypeScript\nimport fetch from 'cross-fetch';\n\n// Using CommonJS modules\nconst fetch = require('cross-fetch');\n```\n\nAs a polyfill:\n\n```javascript\n// Using ES6 modules\nimport 'cross-fetch/polyfill';\n\n// Using CommonJS modules\nrequire('cross-fetch/polyfill');\n```\n\n\nThe CDN build is also available on unpkg:\n\n```html\n<script src=\"//unpkg.com/cross-fetch/dist/cross-fetch.js\"></script>\n```\n\nThis adds the fetch function to the window object. Note that this is not UMD compatible.\n\n\n* * *\n\n## Usage\n\nWith [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise):\n\n```javascript\nimport fetch from 'cross-fetch';\n// Or just: import 'cross-fetch/polyfill';\n\nfetch('//api.github.com/users/lquixada')\n  .then(res => {\n    if (res.status >= 400) {\n      throw new Error(\"Bad response from server\");\n    }\n    return res.json();\n  })\n  .then(user => {\n    console.log(user);\n  })\n  .catch(err => {\n    console.error(err);\n  });\n```\n\nWith [async/await](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function):\n\n```javascript\nimport fetch from 'cross-fetch';\n// Or just: import 'cross-fetch/polyfill';\n\n(async () => {\n  try {\n    const res = await fetch('//api.github.com/users/lquixada');\n    \n    if (res.status >= 400) {\n      throw new Error(\"Bad response from server\");\n    }\n    \n    const user = await res.json();\n  \n    console.log(user);\n  } catch (err) {\n    console.error(err);\n  }\n})();\n```\n\n> ⚠️ **Warning**: If you're in an environment that doesn't support Promises such as Internet Explorer, you must install an ES6 Promise compatible polyfill. [es6-promise](https://github.com/jakearchibald/es6-promise) is suggested.\n\n\n## Demo & API\n\nYou can find a comprehensive doc at [Github's fetch](https://github.github.io/fetch/) page. If you want to play with cross-fetch, check our [**JSFiddle playground**](https://jsfiddle.net/lquixada/3ypqgacp/).\n\n> **Tip**: Run the fiddle on various browsers and with different settings (for instance: cross-domain requests, wrong urls or text requests). Don't forget to open the console in the test suite page and play around.\n\n\n## FAQ\n\n#### Yet another fetch library?\n\nI did a lot of research in order to find a fetch library that could be simple, cross-platform and provide polyfill as an option. There's a plethora of libs out there but none could match those requirements.\n\n\n#### Why not isomorphic-fetch?\n\nMy preferred library used to be [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) but it has this [bug](https://github.com/matthew-andrews/isomorphic-fetch/issues/125) that prevents it from running in a react native environment. It seems unlikely to be fixed since there haven't been any new commits to it since 2016. That means dependencies are outdated as well. \n\n\n#### Why polyfill might not be a good idea?\n\nIn a word? Risk. If the spec changes in the future, it might be problematic to debug. Read more about it on [sindresorhus's ponyfill](https://github.com/sindresorhus/ponyfill#how-are-ponyfills-better-than-polyfills) page. It's up to you if you're fine with it or not.\n\n\n#### How does cross-fetch work?\n\nJust like isomorphic-fetch, it is just a proxy. If you're in node, it delivers you the [node-fetch](https://github.com/bitinn/node-fetch/) library, if you're in a browser or React Native, it delivers you the github's [whatwg-fetch](https://github.com/github/fetch/). The same strategy applies whether you're using polyfill or ponyfill.\n\n\n## Who's Using It?\n\n|[![The New York Times](./docs/images/logo-nytimes.png)](https://www.nytimes.com/)|[![Apollo GraphQL](./docs/images/logo-apollo.png)](https://github.com/apollographql/apollo-client/)|[![Facebook](./docs/images/logo-facebook.png)](https://github.com/facebook/fbjs/)|[![Swagger](./docs/images/logo-swagger.png)](https://swagger.io/)|[![VulcanJS](./docs/images/logo-vulcanjs.png)](http://vulcanjs.org)|[![graphql-request](./docs/images/logo-graphql-request.png)](https://github.com/prisma/graphql-request)|\n|:---:|:---:|:---:|:---:|:---:|:---:|\n|The New York Times|Apollo GraphQL|Facebook|Swagger|VulcanJS|graphql-request|\n\n\n## Thanks\n\nHeavily inspired by the works of [matthew-andrews](https://github.com/matthew-andrews). Kudos to him!\n\n\n## License\n\ncross-fetch is licensed under the [MIT license](https://github.com/lquixada/cross-fetch/blob/main/LICENSE) © [Leonardo Quixadá](https://twitter.com/lquixada/)\n\n\n## Author\n\n|[![@lquixada](https://avatars0.githubusercontent.com/u/195494?v=4&s=96)](https://github.com/lquixada)|\n|:---:|\n|[@lquixada](http://www.github.com/lquixada)|\n","readmeFilename":"README.md"}