{"name":"cross-fetch","version":"2.2.4","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","typings":"index.d.ts","scripts":{"pretest:node:bundle":"webpack-cli --progress --config test/node-bundle/webpack.config.js","build":"rollup -c","codecov":"nyc report --reporter=text-lcov > coverage.lcov && codecov","deploy:major":"npm version major && git push --follow-tags","deploy:minor":"npm version minor && git push --follow-tags","deploy:patch":"npm version patch && git push --follow-tags","lint":"standard","sauce":"./tasks/sauce","security":"snyk test","test":"npm run -s test:browser:headless && npm run -s test:node:plain && npm run -s test:node:bundle && npm run -s lint","test:browser:headless":"mocha-headless-chrome -f test/browser-headless/index.html -a no-sandbox -a disable-setuid-sandbox","test:browser:plain":"opn test/browser/index.html","test:node:bundle":"nyc mocha test/node-bundle/index.js","test:node:plain":"nyc mocha test/node-plain/index.js"},"lint-staged":{"*.js":["standard --fix","git add"]},"husky":{"hooks":{"pre-commit":"npm run -s build && lint-staged"}},"standard":{"env":["mocha","browser"],"globals":["expect","chai","sinon"],"ignore":["/dist/","test/node-bundle/index.js"]},"nyc":{"temp-dir":".reports/.coverage"},"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.1","whatwg-fetch":"2.0.4"},"devDependencies":{"chai":"4.2.0","codecov":"3.1.0","husky":"1.1.2","lint-staged":"7.3.0","mocha":"5.2.0","mocha-headless-chrome":"2.0.1","nock":"10.0.1","nyc":"13.1.0","opn-cli":"3.1.0","ora":"3.0.0","rollup":"0.66.6","rollup-plugin-copy":"0.2.3","rollup-plugin-uglify":"6.0.0","sinon":"7.0.0","snyk":"1.105.0","standard":"12.0.1","webpack":"4.23.0","webpack-cli":"3.1.2"},"keywords":["fetch","isomorphic","universal","node","react","native","browser","ponyfill","whatwg","xhr","ajax"],"readme":"cross-fetch<br>\n[![Build Status](https://travis-ci.org/lquixada/cross-fetch.svg?branch=master)](https://travis-ci.org/lquixada/cross-fetch)\n[![Build Status](https://saucelabs.com/buildstatus/cross-fetch)](https://saucelabs.com/u/cross-fetch)\n[![codecov](https://codecov.io/gh/lquixada/cross-fetch/branch/master/graph/badge.svg)](https://codecov.io/gh/lquixada/cross-fetch)\n[![dependencies Status](https://david-dm.org/lquixada/cross-fetch/status.svg)](https://david-dm.org/lquixada/cross-fetch)\n[![NPM Version](https://img.shields.io/npm/v/cross-fetch.svg?branch=master)](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================\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- **Updated**: latest version of whatwg-fetch and node-fetch used\n\n\n* * *\n\n## Table of Contents\n\n-   [Install](#install)\n-   [Usage](#usage)\n-   [Demo & API](#demo--api)\n-   [FAQ](#faq)\n-   [Supported environments](#supported-environments)\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, these resources can be useful:\n\n* [**JSFiddle playground**](https://jsfiddle.net/lquixada/3ypqgacp/) ➡️\n* [**Public test suite**](https://lquixada.github.io/cross-fetch/test/saucelabs/) ➡️\n\n> **Tip**: Run theses resources 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 it will never be fixed since the author hasn't been committing for more than a year. 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://www.npmjs.com/package/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* [VulcanJS](http://vulcanjs.org)\n* [graphql-request](https://github.com/graphcool/graphql-request)\n* [Swagger](https://swagger.io/)\n\n\n## Supported environments\n\n* Node 6+\n* React-Native\n\n[![Build Status](https://saucelabs.com/browser-matrix/cross-fetch.svg)](https://saucelabs.com/u/cross-fetch)\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/master/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","gitHead":"0820407fd41fd26cb9b9937ae55f96eaabde1a5c","_id":"cross-fetch@2.2.4","_nodeVersion":"8.12.0","_npmVersion":"6.14.2","_npmUser":{"name":"lquixada","email":"lquixada@gmail.com"},"dist":{"integrity":"sha512-mTkfZra7jooqlUdtGRqRMfgG4QJhrrZUvXael4eaq47tOzvgfWh2MKg81KpvSek5Myq7nZJBwxKSOFVT5Ah1EA==","shasum":"c3e04298a684f9a201245ca99079b66c0b0b175d","tarball":"http://registry-npm.ywwl.com/cross-fetch/download/cross-fetch-2.2.4.tgz","fileCount":11,"unpackedSize":68086,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/dF7CRA9TVsSAnZWagAAeikQAI+djCzbs7GBfG/okXlH\nfuJzwllnYip8BF4HKj8QgnO1qc5op3tOOpDoJ+1UHg28MjIMcjxY2uIeSpnz\nIur8wiV25G0iOoSWY1i3a/N8c/6Ou9M3hKHZJ8Ob/Qf6ZNoTEJK2/bpclaA1\nEj0/M+RFaFrL4kCvZGc5vV/YKn/IVgg4CyZ7/blDK7jRI8PV02qEUrTJVM9n\ntUtE8oUHWPW4lUA22cBZe3q4aogiPqzjNtDYSAtwJJEkAndandWUCbBa5mQ5\nDd1zKVggzyTWq2lTx+xMsEOnXX7/ZF0Y2JryuWs0Ry7BxoOjywEtasA/ZP2j\ng66Tum8MU/Un5J9Gfluqmjr9/gG9QvlPZXCG41r2O/SEupx4oRreEdBP9pT2\nbDRjd6RdcnDDuDDEDjXHpF3Ft2fZWpX5/xgEN4h2DRwxIrgaP7wIlUKKaIUU\nZSFoXfCUhkjQwb5aEo24aPNfLpct8eNzn9w9alzezgVGrs5ysKgIM3FQkDnu\n76CCYp+JvLyhzvs3QZWi97UBJJRG8SRvemaT4g09DmB3bwH4fpy7tF33RGYq\nRUvolcPLqe5XM5MWO6ffDIKvKRtUbw5PrtvvSb184VM0aAfCcz27/JPhoPWe\nJbAqiVH70EGVQL7TYP8s5+qZlKdoTR45oAvF/5WTFkDd+QGYlQWL205PoMaN\nwuVC\r\n=cH5w\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA/bTui6JdVY9IImsgCUXyPAIfYEPXcMWJ/fcZJCeji2AiEAjP0ar2EIpn9m7nMw6lbM/xsksquj87eSPy6qiBsbiY4="}],"size":15922,"noattachment":false,"key":"/cross-fetch/-/cross-fetch-2.2.4.tgz"},"directories":{},"maintainers":[{"name":"lquixada","email":"lquixada@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cross-fetch_2.2.4_1627246971364_0.5837339082600108"},"_hasShrinkwrap":false,"publish_time":1627246971554,"_cnpm_publish_time":1627246971554,"dist-tags":{"latest":"4.1.0","latest-v2.x":"2.2.6","latest-v3.x":"3.2.0","latest-v4.x":"4.1.0"}}