{"_id":"node-fetch-unix","_rev":"4-3cd42160fac044f000f9056223ae0754","name":"node-fetch-unix","dist-tags":{"latest":"2.3.0"},"versions":{"2.1.2-rc.1":{"name":"node-fetch-unix","version":"2.1.2-rc.1","description":"A light-weight module that brings window.fetch to node.js","main":"lib/index.js","browser":"./browser.js","module":"lib/index.es.js","files":["lib/index.js","lib/index.es.js","browser.js"],"engines":{"node":"4.x || >=6.0.0"},"scripts":{"build":"cross-env BABEL_ENV=rollup rollup -c","prepare":"npm run build","test":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test.js","test-unix":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test-unix.js","report":"cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js","coverage":"cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"},"repository":{"type":"git","url":"git+https://github.com/liangxingchen/node-fetch-unix.git"},"keywords":["fetch","http","promise"],"author":{"name":"David Frank"},"license":"MIT","bugs":{"url":"https://github.com/liangxingchen/node-fetch-unix/issues"},"homepage":"https://github.com/liangxingchen/node-fetch-unix","devDependencies":{"babel-core":"^6.26.0","babel-plugin-istanbul":"^4.1.5","babel-preset-env":"^1.6.1","babel-register":"^6.16.3","chai":"^3.5.0","chai-as-promised":"^7.1.1","chai-iterator":"^1.1.1","chai-string":"^1.3.0","codecov":"^3.0.0","cross-env":"^5.1.3","form-data":"^2.3.1","mocha":"^5.0.0","nyc":"^11.4.1","parted":"^0.1.1","promise":"^8.0.1","resumer":"0.0.0","rollup":"^0.55.1","rollup-plugin-babel":"^3.0.3","string-to-arraybuffer":"^1.0.0","url-search-params":"^0.10.0","whatwg-url":"^5.0.0"},"dependencies":{},"gitHead":"fde713796fac7770f44378b135b491c36ec0f570","_id":"node-fetch-unix@2.1.2-rc.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"liangxingchen","email":"liang@maichong.it"},"dist":{"integrity":"sha512-DBMpsoIiPVlnI0HKmwmRx4KDgYhZNIvNGJtO/eDf+vAPQOmvtyA1wE7AcymDX/ntdITrghawZ2qzWJdUEZtYaA==","shasum":"e9e0f1cfeff7e29d98a79432219c1a6c34fd7dd0","tarball":"https://registry.npmjs.org/node-fetch-unix/-/node-fetch-unix-2.1.2-rc.1.tgz","fileCount":7,"unpackedSize":102156,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8mr6CRA9TVsSAnZWagAA1IQP/jQA0EFdOFxeJy/1aWZk\nCH2ntg6yZ0DyTs4y66Ji8oPosy16jn7oFkud0HGKsEOH5Cgyu1vMeLrl0/ct\n6a4baIEtab+sQJEZVva1p6E0sFrHU13ACursVjJIf9RHyUGFJNvw3ppfBok9\nfP/sx7fdlk09F7tjWPvJLXz/opADpGRFHxI4aKcbyN9zwLfKQnXX7P6DvusD\nGpWqYeJAKNuBixsRsy8I9zsGLcbRsxPWDuZNImouUz7o7qBPVaCECT/jVun3\nKfHzJaDxJC5Vgehx7uRKpHpBrQVsCiXVrWVlcdImlq3hSodMNnHTZJFchL9M\nX1uFIt6M7RtZY9A3u/zn3hZ4l9ir6kK73i7IkqtVnKSZWS+MqCJSi3eJzerg\nxJJfsqlw1jcRdA4Ii/jai3K0C28c6qMad8gQaJd07W+6K1hYRABrBjzNlnni\nXWdnUFaz//MoysfzJfIPxQia/weei7pe+B9EVMpDczWUsbEffPMrXuDRWnru\nWY37A+BPGqFVQCLtyPuztN1abAwIqyFWgMSlsxboNqnRMDrgZI4uWy23oLAZ\n6hp3yWnD3g/ElTvAGLTflAVfA4QCDIx9USn/FmpjvH0dEdYmMo9pins6W0+k\nj7qEsy0cH2te5JIss0NpGGVg7M2smdjzntJS/VXCLTVVY0BdBsmOZ63ZnBfA\nUTeP\r\n=tQcu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkAj1SvA2NgujZDq2FgaNSlzeDTDrHVgfMFWQKrqlmagIhAJVmxgZrMvP45fMI3OC7dlqVnz5I0Cah8yzXg2hXsCqh"}]},"maintainers":[{"name":"liangxingchen","email":"liang@maichong.it"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-fetch-unix_2.1.2-rc.1_1525836536554_0.4138834530383464"},"_hasShrinkwrap":false},"2.1.2-rc.2":{"name":"node-fetch-unix","version":"2.1.2-rc.2","description":"A light-weight module that brings window.fetch to node.js","main":"lib/index.js","browser":"./browser.js","module":"lib/index.es.js","files":["lib/index.js","lib/index.es.js","browser.js"],"engines":{"node":"4.x || >=6.0.0"},"scripts":{"build":"cross-env BABEL_ENV=rollup rollup -c","prepare":"npm run build","test":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test.js","test-unix":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test-unix.js","report":"cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js","coverage":"cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"},"repository":{"type":"git","url":"git+https://github.com/liangxingchen/node-fetch-unix.git"},"keywords":["fetch","http","promise"],"author":{"name":"David Frank"},"license":"MIT","bugs":{"url":"https://github.com/liangxingchen/node-fetch-unix/issues"},"homepage":"https://github.com/liangxingchen/node-fetch-unix","devDependencies":{"babel-core":"^6.26.0","babel-plugin-istanbul":"^4.1.5","babel-preset-env":"^1.6.1","babel-register":"^6.16.3","chai":"^3.5.0","chai-as-promised":"^7.1.1","chai-iterator":"^1.1.1","chai-string":"^1.3.0","codecov":"^3.0.0","cross-env":"^5.1.3","form-data":"^2.3.1","mocha":"^5.0.0","nyc":"^11.4.1","parted":"^0.1.1","promise":"^8.0.1","resumer":"0.0.0","rollup":"^0.55.1","rollup-plugin-babel":"^3.0.3","string-to-arraybuffer":"^1.0.0","url-search-params":"^0.10.0","whatwg-url":"^5.0.0"},"dependencies":{},"gitHead":"fde713796fac7770f44378b135b491c36ec0f570","_id":"node-fetch-unix@2.1.2-rc.2","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"liangxingchen","email":"liang@maichong.it"},"dist":{"integrity":"sha512-LdNspniMHbEjdY43e/r/wL06lzSpRNRV1dXsNaPAbrPex9q3RVpGB50c0U+72mqUSGcuvGI7kccUFaHX8Tjqvg==","shasum":"06aaa7020ddb054b526c431c1c2801f35a518a15","tarball":"https://registry.npmjs.org/node-fetch-unix/-/node-fetch-unix-2.1.2-rc.2.tgz","fileCount":7,"unpackedSize":102374,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8odJCRA9TVsSAnZWagAASKAP/1Ebz6HnAG1HUmoi9RbH\nF61vuptuNdL/4vpM6Og/Svx7HGw7Y6+DbWSw0OOTiyDJWxO1Nrv6E8TTBl/6\n7D2x2rXmoo1DirIX0KqHfuziBucvZca96X+H9Sb1XEr4gEZWj3kbDzf+Igv8\nzvculTg69uYlGuPcUWJDhlsxJuXC/8r1kNs99Mz0pfA8fuia1kk7vCwFdkqv\nmYWRqKIhl0J1cnEEIXlQQlKG2+wRhyk/FzYtgWYytNgjPol0Eib0pdx4fjPd\nTxMNZJsXMes7a6rVUlJfocMRb5/sBG3r2fB10TdJ6zyLU8xd62jcnrpddWDU\ntxah48eWihPW9cgkqC+V0nhOnNaQNIsoTITBEbj5qxsm8fK/vd74Cb1gUmZo\nDVZXjPccSOUp1k+Lb7qNqCDWLTH31Ib65ujUi1lEDTLYKNhupKZ/dpZ+gH9n\nAK5l0A7InVL+19uxnR+9p4IDIkQ6kx0IsPOCTSeCE6rsIs7InrLi/4YycsJw\n4m0ZreTHVpeJqyECdMoqJW5LMdadMh6KJspHS3Q6lIJHIj1czJAqBEQG1svp\n4grLhyA0UKUKSNmpFgjqstz8FFCX4w8ijIdl2dJrFb9ZW5RP3eGQooAWSbx9\nJEIi3mD2AfPv67ZbaU+617xhstvWHRjC/y2Fpd9vjxCKQzADgXhMo2aE2u29\nBG+9\r\n=vKWr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDQN9wEllUij1ZvcRhRhK62tpFvUBmvHy44sDvHPGqYwwIhAKTWSFWUImADz4eWL6sA3ptxctM65/FgMFpdvKdQj6O7"}]},"maintainers":[{"name":"liangxingchen","email":"liang@maichong.it"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-fetch-unix_2.1.2-rc.2_1525843783862_0.6214568343285201"},"_hasShrinkwrap":false},"2.1.2-rc.3":{"name":"node-fetch-unix","version":"2.1.2-rc.3","description":"A light-weight module that brings window.fetch to node.js","main":"lib/index.js","browser":"./browser.js","module":"lib/index.es.js","files":["lib/index.js","lib/index.es.js","browser.js"],"engines":{"node":"4.x || >=6.0.0"},"scripts":{"build":"cross-env BABEL_ENV=rollup rollup -c","prepare":"npm run build","test":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test.js","test-unix":"cross-env BABEL_ENV=test mocha --compilers js:babel-register test/test-unix.js","report":"cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js","coverage":"cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"},"repository":{"type":"git","url":"git+https://github.com/liangxingchen/node-fetch-unix.git"},"keywords":["fetch","http","promise"],"author":{"name":"David Frank"},"license":"MIT","bugs":{"url":"https://github.com/liangxingchen/node-fetch-unix/issues"},"homepage":"https://github.com/liangxingchen/node-fetch-unix","devDependencies":{"babel-core":"^6.26.0","babel-plugin-istanbul":"^4.1.5","babel-preset-env":"^1.6.1","babel-register":"^6.16.3","chai":"^3.5.0","chai-as-promised":"^7.1.1","chai-iterator":"^1.1.1","chai-string":"^1.3.0","codecov":"^3.0.0","cross-env":"^5.1.3","form-data":"^2.3.1","mocha":"^5.0.0","nyc":"^11.4.1","parted":"^0.1.1","promise":"^8.0.1","resumer":"0.0.0","rollup":"^0.55.1","rollup-plugin-babel":"^3.0.3","string-to-arraybuffer":"^1.0.0","url-search-params":"^0.10.0","whatwg-url":"^5.0.0"},"dependencies":{},"gitHead":"fde713796fac7770f44378b135b491c36ec0f570","_id":"node-fetch-unix@2.1.2-rc.3","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"liangxingchen","email":"liang@maichong.it"},"dist":{"integrity":"sha512-4i8tHCoI1W/yl863xJoLbHAzwc06bWX5WEw67WaA9k/So72ANNCqPv+bmngVvuxqMl2m+kO46YQlfigybgLd+A==","shasum":"8ca0730cb5214d4227cde88816b16e6986369d31","tarball":"https://registry.npmjs.org/node-fetch-unix/-/node-fetch-unix-2.1.2-rc.3.tgz","fileCount":7,"unpackedSize":102544,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8onPCRA9TVsSAnZWagAA4CQP/3M2p71/rRlLxMYPFr1j\nw+BJtJ05gD4ThmbBmy+XYbkxFOxOb21a26KMjePd+tx0YotxFoCy2K3da/n6\nvAIpFL0FGnlucnJq4+k2Gj/hrngX3AgwYoEJgINQZkunMD+g5w2wHHopZELN\nnUzWSR5/KXqxc/oZRvtFrjdQrlHgo/VdF7i1WTRcpjWbhHp0hH+BF55TTi7q\n/mpdruym9DfZWHS86isGQQD+UtndMHyFv7CwQwHAuCvK2m1qFVcLMITgMUWV\nI9cDeYB0l0fkPkqka4/ptFnF+FPmxiV/mWuLTp5SvTsNIcH59alXQzFe/HJ5\n0NAnZttRYzgWtGLrXkWSi4hRb2nes2NUd5LriBAuD98mWj0K60uPEWjWjHj6\nYoxHXpJqFkUXmWTbBkDBq1cEwNycgZIxnV1cYI09A9wI50xO/n0NJXhEUXVz\n0kBnVGtK8/aXYXeDSeZZkCOD9YKBda80HJypiTMQ+1WyivIsLMhssyY4MrrW\ndwyeYG92URQwPC3ppzzsiHmu3mHLeBQCU8jtHIGBcLtDt3IdKHSxpbi9q0cr\n0FH8xPVn/DX0Zlb1spimn0v6/erHfnB9dbLSKBZ7D15m/UR7srNX7Dmk11HA\no5eP83y5SqOJ/p4OfyQG+OnXl7m4jh/0L/2QworkWfCauh2RSMCX9WduzdpD\nJItg\r\n=xI1H\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG+biAzQD3QRWwRCNNIj93IGsOUbLyWcqk0J2jK261i6AiBFgerRFGeJAwBeob+0DeCNVBg3o9km7fyvslSbH3nIbg=="}]},"maintainers":[{"name":"liangxingchen","email":"liang@maichong.it"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-fetch-unix_2.1.2-rc.3_1525844431059_0.5320124996216"},"_hasShrinkwrap":false},"2.3.0":{"name":"node-fetch-unix","version":"2.3.0","description":"A light-weight module that brings window.fetch to node.js","main":"lib/index","browser":"./browser.js","module":"lib/index.mjs","engines":{"node":"4.x || >=6.0.0"},"scripts":{"build":"cross-env BABEL_ENV=rollup rollup -c","prepare":"npm run build","test":"cross-env BABEL_ENV=test mocha --require babel-register test/test.js","test-unix":"cross-env BABEL_ENV=test mocha --require babel-register test/test-unix.js","report":"cross-env BABEL_ENV=coverage nyc --reporter lcov --reporter text mocha -R spec test/test.js","coverage":"cross-env BABEL_ENV=coverage nyc --reporter json --reporter text mocha -R spec test/test.js && codecov -f coverage/coverage-final.json"},"repository":{"type":"git","url":"git+https://github.com/liangxingchen/node-fetch-unix.git"},"keywords":["fetch","http","promise"],"author":{"name":"David Frank"},"license":"MIT","bugs":{"url":"https://github.com/liangxingchen/node-fetch-unix/issues"},"homepage":"https://github.com/liangxingchen/node-fetch-unix","devDependencies":{"abort-controller":"^1.0.2","abortcontroller-polyfill":"^1.1.9","babel-core":"^6.26.0","babel-plugin-istanbul":"^4.1.5","babel-preset-env":"^1.6.1","babel-register":"^6.16.3","chai":"^3.5.0","chai-as-promised":"^7.1.1","chai-iterator":"^1.1.1","chai-string":"~1.3.0","codecov":"^3.0.0","cross-env":"^5.1.3","form-data":"^2.3.1","is-builtin-module":"^1.0.0","mocha":"^5.0.0","nyc":"11.9.0","parted":"^0.1.1","promise":"^8.0.1","resumer":"0.0.0","rollup":"^0.63.4","rollup-plugin-babel":"^3.0.3","string-to-arraybuffer":"^1.0.0","url-search-params":"^1.0.2","whatwg-url":"^5.0.0"},"dependencies":{},"gitHead":"d3fe1ba312087437fc4a254783745e749146298e","_id":"node-fetch-unix@2.3.0","_npmVersion":"6.4.1","_nodeVersion":"10.14.1","_npmUser":{"name":"liangxingchen","email":"liang@maichong.it"},"dist":{"integrity":"sha512-ngVgjZl1n1dZRR8BIX/UKU3Q0cfkQ4byUVcV132xW/+zPF79sVo2td2576mzIGJibi7E0Azcx2gpy66BoV2hrg==","shasum":"b5e49024846ed86aa14c2f0e418fd46850266d4d","tarball":"https://registry.npmjs.org/node-fetch-unix/-/node-fetch-unix-2.3.0.tgz","fileCount":8,"unpackedSize":152615,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcgOQ0CRA9TVsSAnZWagAAchYP/2znxgswuzO54DepSzHQ\nYxZVWLuweCPNwcHD+09BZsdC9Th6rXjPGmct+e+NkN7n6R5oEmSaRe29Jbmj\nZF/2bG4ll1T9hQLAujEuOFuRhxyVTE4d2ush8qWOjjoeoGiuD0yRk7/0oVv9\ngOwlv5F7U7tRTGcInAlvJkULr5BmNYOG4uGkOBYPUYZFU3livz+KrOnrfG/2\n6zvFvVLCfOkEH4uSnuT9M6BPn5ZcYRSzcZP8od13z+r8AWG1ffuRjQUdFUXY\nmO9zfMcgYyx1c/cPgsSo2PGAqzG5bwNSH98cQbs29yUSEwDUdG39TU4VzINI\nl32LBNJ8Vj7MiwH8nS5WyGrPY4qKiSbykPKNjJ8ymndMSt8P5mHlytZeqqpG\nmyFjLBimQsceD6qrNLFuQ1NTgyrMIFove5FrsMTmEmzzFd+4vSONkeEdDbXp\nb1lRxdMbtQuh3nEtAeN4oq+WL8mF0NNvzO1XC2/M5MzZolgQOaghmLu7HR26\n+ffoaH7H2kfSc0sOG176dchFkGqW51nHMUOA/4F9fWF3hcmdOKG2tmI/lJW5\nwU3/x/79xMpwsQlRMXKhPTii+AWbc6+dGLcjULVZMfitQ8th6iRfMwe2hxXv\nNufTmQY8Bz5KjEcwksrYgyzGgDOsDnn3ktu1MqMxiCQ5Bs8xAlJZiPS6UGmT\nnWCt\r\n=N5dO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCh1ZGKTP2+c7Wj/hFGtkEs36O9WmHJ066y1XDZXSSQ4AIgCSzBBslqRoU1fM+E8V6pBbCyAeRH+/hByBs+B2jMDJM="}]},"maintainers":[{"name":"liangxingchen","email":"liang@maichong.it"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-fetch-unix_2.3.0_1551950899801_0.43349909746784276"},"_hasShrinkwrap":false}},"time":{"created":"2018-05-09T03:28:56.554Z","2.1.2-rc.1":"2018-05-09T03:28:56.676Z","modified":"2022-05-11T00:44:34.145Z","2.1.2-rc.2":"2018-05-09T05:29:43.995Z","2.1.2-rc.3":"2018-05-09T05:40:31.135Z","2.3.0":"2019-03-07T09:28:20.009Z"},"maintainers":[{"name":"liangxingchen","email":"liang@maichong.it"}],"description":"A light-weight module that brings window.fetch to node.js","homepage":"https://github.com/liangxingchen/node-fetch-unix","keywords":["fetch","http","promise"],"repository":{"type":"git","url":"git+https://github.com/liangxingchen/node-fetch-unix.git"},"author":{"name":"David Frank"},"bugs":{"url":"https://github.com/liangxingchen/node-fetch-unix/issues"},"license":"MIT","readme":"node-fetch\n==========\n\n[![npm version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![coverage status][codecov-image]][codecov-url]\n[![install size][install-size-image]][install-size-url]\n\nA light-weight module that brings `window.fetch` to Node.js\n\n(We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567))\n\n<!-- TOC -->\n\n- [Motivation](#motivation)\n- [Features](#features)\n- [Difference from client-side fetch](#difference-from-client-side-fetch)\n- [Installation](#installation)\n- [Loading and configuring the module](#loading-and-configuring-the-module)\n- [Common Usage](#common-usage)\n    - [Plain text or HTML](#plain-text-or-html)\n    - [JSON](#json)\n    - [Simple Post](#simple-post)\n    - [Post with JSON](#post-with-json)\n    - [Post with form parameters](#post-with-form-parameters)\n    - [Handling exceptions](#handling-exceptions)\n    - [Handling client and server errors](#handling-client-and-server-errors)\n- [Advanced Usage](#advanced-usage)\n    - [Streams](#streams)\n    - [Buffer](#buffer)\n    - [Accessing Headers and other Meta data](#accessing-headers-and-other-meta-data)\n    - [Post data using a file stream](#post-data-using-a-file-stream)\n    - [Post with form-data (detect multipart)](#post-with-form-data-detect-multipart)\n    - [Request cancellation with AbortSignal](#request-cancellation-with-abortsignal)\n- [API](#api)\n    - [fetch(url[, options])](#fetchurl-options)\n    - [Options](#options)\n    - [Class: Request](#class-request)\n    - [Class: Response](#class-response)\n    - [Class: Headers](#class-headers)\n    - [Interface: Body](#interface-body)\n    - [Class: FetchError](#class-fetcherror)\n- [License](#license)\n- [Acknowledgement](#acknowledgement)\n\n<!-- /TOC -->\n\n## Motivation\n\nInstead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime.\n\nSee Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side).\n\n## Features\n\n- Stay consistent with `window.fetch` API.\n- Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences.\n- Use native promise, but allow substituting it with [insert your favorite promise library].\n- Use native Node streams for body, on both request and response.\n- Decode content encoding (gzip/deflate) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically.\n- Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting.\n\n## Difference from client-side fetch\n\n- See [Known Differences](LIMITS.md) for details.\n- If you happen to use a missing feature that `window.fetch` offers, feel free to open an issue.\n- Pull requests are welcomed too!\n\n## Installation\n\nCurrent stable release (`2.x`)\n\n```sh\n$ npm install node-fetch --save\n```\n\n## Loading and configuring the module\nWe suggest you load the module via `require`, pending the stabalizing of es modules in node:\n```js\nconst fetch = require('node-fetch');\n```\n\nIf you are using a Promise library other than native, set it through fetch.Promise:\n```js\nconst Bluebird = require('bluebird');\n\nfetch.Promise = Bluebird;\n```\n\n## Common Usage\n\nNOTE: The documentation below is up-to-date with `2.x` releases, [see `1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences.\n\n#### Plain text or HTML\n```js\nfetch('https://github.com/')\n    .then(res => res.text())\n    .then(body => console.log(body));\n```\n\n#### JSON\n\n```js\n\nfetch('https://api.github.com/users/github')\n    .then(res => res.json())\n    .then(json => console.log(json));\n```\n\n#### Simple Post\n```js\nfetch('https://httpbin.org/post', { method: 'POST', body: 'a=1' })\n    .then(res => res.json()) // expecting a json response\n    .then(json => console.log(json));\n```\n\n#### Post with JSON\n\n```js\nconst body = { a: 1 };\n\nfetch('https://httpbin.org/post', {\n        method: 'post',\n        body:    JSON.stringify(body),\n        headers: { 'Content-Type': 'application/json' },\n    })\n    .then(res => res.json())\n    .then(json => console.log(json));\n```\n\n#### Post with form parameters\n`URLSearchParams` is available in Node.js as of v7.5.0. See [official documentation](https://nodejs.org/api/url.html#url_class_urlsearchparams) for more usage methods.\n\nNOTE: The `Content-Type` header is only set automatically to `x-www-form-urlencoded` when an instance of `URLSearchParams` is given as such:\n\n```js\nconst { URLSearchParams } = require('url');\n\nconst params = new URLSearchParams();\nparams.append('a', 1);\n\nfetch('https://httpbin.org/post', { method: 'POST', body: params })\n    .then(res => res.json())\n    .then(json => console.log(json));\n```\n\n#### Handling exceptions\nNOTE: 3xx-5xx responses are *NOT* exceptions, and should be handled in `then()`, see the next section.\n\nAdding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md)  for more details.\n\n```js\nfetch('https://domain.invalid/')\n    .catch(err => console.error(err));\n```\n\n#### Handling client and server errors\nIt is common to create a helper function to check that the response contains no client (4xx) or server (5xx) error responses:\n\n```js\nfunction checkStatus(res) {\n    if (res.ok) { // res.status >= 200 && res.status < 300\n        return res;\n    } else {\n        throw MyCustomError(res.statusText);\n    }\n}\n\nfetch('https://httpbin.org/status/400')\n    .then(checkStatus)\n    .then(res => console.log('will not get here...'))\n```\n\n## Advanced Usage\n\n#### Streams\nThe \"Node.js way\" is to use streams when possible:\n\n```js\nfetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')\n    .then(res => {\n        const dest = fs.createWriteStream('./octocat.png');\n        res.body.pipe(dest);\n    });\n```\n\n#### Buffer\nIf you prefer to cache binary data in full, use buffer(). (NOTE: buffer() is a `node-fetch` only API)\n\n```js\nconst fileType = require('file-type');\n\nfetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')\n    .then(res => res.buffer())\n    .then(buffer => fileType(buffer))\n    .then(type => { /* ... */ });\n```\n\n#### Accessing Headers and other Meta data\n```js\nfetch('https://github.com/')\n    .then(res => {\n        console.log(res.ok);\n        console.log(res.status);\n        console.log(res.statusText);\n        console.log(res.headers.raw());\n        console.log(res.headers.get('content-type'));\n    });\n```\n\n#### Post data using a file stream\n\n```js\nconst { createReadStream } = require('fs');\n\nconst stream = createReadStream('input.txt');\n\nfetch('https://httpbin.org/post', { method: 'POST', body: stream })\n    .then(res => res.json())\n    .then(json => console.log(json));\n```\n\n#### Post with form-data (detect multipart)\n\n```js\nconst FormData = require('form-data');\n\nconst form = new FormData();\nform.append('a', 1);\n\nfetch('https://httpbin.org/post', { method: 'POST', body: form })\n    .then(res => res.json())\n    .then(json => console.log(json));\n\n// OR, using custom headers\n// NOTE: getHeaders() is non-standard API\n\nconst form = new FormData();\nform.append('a', 1);\n\nconst options = {\n    method: 'POST',\n    body: form,\n    headers: form.getHeaders()\n}\n\nfetch('https://httpbin.org/post', options)\n    .then(res => res.json())\n    .then(json => console.log(json));\n```\n\n#### Request cancellation with AbortSignal\n\n> NOTE: You may only cancel streamed requests on Node >= v8.0.0\n\nYou may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller).\n\nAn example of timing out a request after 150ms could be achieved as follows:\n\n```js\nimport AbortController from 'abort-controller';\n\nconst controller = new AbortController();\nconst timeout = setTimeout(\n  () => { controller.abort(); },\n  150,\n);\n\nfetch(url, { signal: controller.signal })\n  .then(res => res.json())\n  .then(\n    data => {\n      useData(data)\n    },\n    err => {\n      if (err.name === 'AbortError') {\n        // request was aborted\n      }\n    },\n  )\n  .finally(() => {\n    clearTimeout(timeout);\n  });\n```\n\nSee [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for more examples.\n\n\n## API\n\n### fetch(url[, options])\n\n- `url` A string representing the URL for fetching\n- `options` [Options](#fetch-options) for the HTTP(S) request\n- Returns: <code>Promise&lt;[Response](#class-response)&gt;</code>\n\nPerform an HTTP(S) fetch.\n\n`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected promise.\n\n<a id=\"fetch-options\"></a>\n### Options\n\nThe default values are shown after each option key.\n\n```js\n{\n    // These properties are part of the Fetch Standard\n    method: 'GET',\n    headers: {},        // request headers. format is the identical to that accepted by the Headers constructor (see below)\n    body: null,         // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream\n    redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect\n    signal: null,       // pass an instance of AbortSignal to optionally abort requests\n\n    // The following properties are node-fetch extensions\n    follow: 20,         // maximum redirect count. 0 to not follow redirect\n    timeout: 0,         // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies). Signal is recommended instead.\n    compress: true,     // support gzip/deflate content encoding. false to disable\n    size: 0,            // maximum response body size in bytes. 0 to disable\n    agent: null         // http(s).Agent instance, allows custom proxy, certificate, dns lookup etc.\n}\n```\n\n##### Default Headers\n\nIf no values are set, the following request headers will be sent automatically:\n\nHeader              | Value\n------------------- | --------------------------------------------------------\n`Accept-Encoding`   | `gzip,deflate` _(when `options.compress === true`)_\n`Accept`            | `*/*`\n`Connection`        | `close` _(when no `options.agent` is present)_\n`Content-Length`    | _(automatically calculated, if possible)_\n`Transfer-Encoding` | `chunked` _(when `req.body` is a stream)_\n`User-Agent`        | `node-fetch/1.0 (+https://github.com/bitinn/node-fetch)`\n\n<a id=\"class-request\"></a>\n### Class: Request\n\nAn HTTP(S) request containing information about URL, method, headers, and the body. This class implements the [Body](#iface-body) interface.\n\nDue to the nature of Node.js, the following properties are not implemented at this moment:\n\n- `type`\n- `destination`\n- `referrer`\n- `referrerPolicy`\n- `mode`\n- `credentials`\n- `cache`\n- `integrity`\n- `keepalive`\n\nThe following node-fetch extension properties are provided:\n\n- `follow`\n- `compress`\n- `counter`\n- `agent`\n\nSee [options](#fetch-options) for exact meaning of these extensions.\n\n#### new Request(input[, options])\n\n<small>*(spec-compliant)*</small>\n\n- `input` A string representing a URL, or another `Request` (which will be cloned)\n- `options` [Options][#fetch-options] for the HTTP(S) request\n\nConstructs a new `Request` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request).\n\nIn most cases, directly `fetch(url, options)` is simpler than creating a `Request` object.\n\n<a id=\"class-response\"></a>\n### Class: Response\n\nAn HTTP(S) response. This class implements the [Body](#iface-body) interface.\n\nThe following properties are not implemented in node-fetch at this moment:\n\n- `Response.error()`\n- `Response.redirect()`\n- `type`\n- `redirected`\n- `trailer`\n\n#### new Response([body[, options]])\n\n<small>*(spec-compliant)*</small>\n\n- `body` A string or [Readable stream][node-readable]\n- `options` A [`ResponseInit`][response-init] options dictionary\n\nConstructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response).\n\nBecause Node.js does not implement service workers (for which this class was designed), one rarely has to construct a `Response` directly.\n\n#### response.ok\n\n<small>*(spec-compliant)*</small>\n\nConvenience property representing if the request ended normally. Will evaluate to true if the response status was greater than or equal to 200 but smaller than 300.\n\n<a id=\"class-headers\"></a>\n### Class: Headers\n\nThis class allows manipulating and iterating over a set of HTTP headers. All methods specified in the [Fetch Standard][whatwg-fetch] are implemented.\n\n#### new Headers([init])\n\n<small>*(spec-compliant)*</small>\n\n- `init` Optional argument to pre-fill the `Headers` object\n\nConstruct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object, or any iterable object.\n\n```js\n// Example adapted from https://fetch.spec.whatwg.org/#example-headers-class\n\nconst meta = {\n  'Content-Type': 'text/xml',\n  'Breaking-Bad': '<3'\n};\nconst headers = new Headers(meta);\n\n// The above is equivalent to\nconst meta = [\n  [ 'Content-Type', 'text/xml' ],\n  [ 'Breaking-Bad', '<3' ]\n];\nconst headers = new Headers(meta);\n\n// You can in fact use any iterable objects, like a Map or even another Headers\nconst meta = new Map();\nmeta.set('Content-Type', 'text/xml');\nmeta.set('Breaking-Bad', '<3');\nconst headers = new Headers(meta);\nconst copyOfHeaders = new Headers(headers);\n```\n\n<a id=\"iface-body\"></a>\n### Interface: Body\n\n`Body` is an abstract interface with methods that are applicable to both `Request` and `Response` classes.\n\nThe following methods are not yet implemented in node-fetch at this moment:\n\n- `formData()`\n\n#### body.body\n\n<small>*(deviation from spec)*</small>\n\n* Node.js [`Readable` stream][node-readable]\n\nThe data encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable].\n\n#### body.bodyUsed\n\n<small>*(spec-compliant)*</small>\n\n* `Boolean`\n\nA boolean property for if this body has been consumed. Per spec, a consumed body cannot be used again.\n\n#### body.arrayBuffer()\n#### body.blob()\n#### body.json()\n#### body.text()\n\n<small>*(spec-compliant)*</small>\n\n* Returns: <code>Promise</code>\n\nConsume the body and return a promise that will resolve to one of these formats.\n\n#### body.buffer()\n\n<small>*(node-fetch extension)*</small>\n\n* Returns: <code>Promise&lt;Buffer&gt;</code>\n\nConsume the body and return a promise that will resolve to a Buffer.\n\n#### body.textConverted()\n\n<small>*(node-fetch extension)*</small>\n\n* Returns: <code>Promise&lt;String&gt;</code>\n\nIdentical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8, if possible.\n\n(This API requires an optional dependency on npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.)\n\n<a id=\"class-fetcherror\"></a>\n### Class: FetchError\n\n<small>*(node-fetch extension)*</small>\n\nAn operational error in the fetching process. See [ERROR-HANDLING.md][] for more info.\n\n<a id=\"class-aborterror\"></a>\n### Class: AbortError\n\n<small>*(node-fetch extension)*</small>\n\nAn Error thrown when the request is aborted in response to an `AbortSignal`'s `abort` event. It has a `name` property of `AbortError`. See [ERROR-HANDLING.MD][] for more info.\n\n## Acknowledgement\n\nThanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference.\n\n`node-fetch` v1 was maintained by [@bitinn](https://github.com/bitinn), v2 is currently maintained by [@TimothyGu](https://github.com/timothygu), v2 readme is written by [@jkantr](https://github.com/jkantr).\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/node-fetch.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/node-fetch\n[travis-image]: https://img.shields.io/travis/bitinn/node-fetch.svg?style=flat-square\n[travis-url]: https://travis-ci.org/bitinn/node-fetch\n[codecov-image]: https://img.shields.io/codecov/c/github/bitinn/node-fetch.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/bitinn/node-fetch\n[install-size-image]: https://packagephobia.now.sh/badge?p=node-fetch\n[install-size-url]: https://packagephobia.now.sh/result?p=node-fetch\n[whatwg-fetch]: https://fetch.spec.whatwg.org/\n[response-init]: https://fetch.spec.whatwg.org/#responseinit\n[node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams\n[mdn-headers]: https://developer.mozilla.org/en-US/docs/Web/API/Headers\n[LIMITS.md]: https://github.com/bitinn/node-fetch/blob/master/LIMITS.md\n[ERROR-HANDLING.md]: https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md\n[UPGRADE-GUIDE.md]: https://github.com/bitinn/node-fetch/blob/master/UPGRADE-GUIDE.md\n","readmeFilename":"README.md"}