111 lines
9.2 KiB
JSON
111 lines
9.2 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "node-fetch@^1.0.1",
|
|
"scope": null,
|
|
"escapedName": "node-fetch",
|
|
"name": "node-fetch",
|
|
"rawSpec": "^1.0.1",
|
|
"spec": ">=1.0.1 <2.0.0",
|
|
"type": "range"
|
|
},
|
|
"/home/jdaugherty/work/GT2/GT2-Android/node_modules/isomorphic-fetch"
|
|
]
|
|
],
|
|
"_from": "node-fetch@>=1.0.1 <2.0.0",
|
|
"_id": "node-fetch@1.7.3",
|
|
"_inCache": true,
|
|
"_location": "/node-fetch",
|
|
"_nodeVersion": "8.2.1",
|
|
"_npmOperationalInternal": {
|
|
"host": "s3://npm-registry-packages",
|
|
"tmp": "tmp/node-fetch-1.7.3.tgz_1504852098188_0.7899843158666044"
|
|
},
|
|
"_npmUser": {
|
|
"name": "bitinn",
|
|
"email": "bitinn@gmail.com"
|
|
},
|
|
"_npmVersion": "5.3.0",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "node-fetch@^1.0.1",
|
|
"scope": null,
|
|
"escapedName": "node-fetch",
|
|
"name": "node-fetch",
|
|
"rawSpec": "^1.0.1",
|
|
"spec": ">=1.0.1 <2.0.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/isomorphic-fetch"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
|
|
"_shasum": "980f6f72d85211a5347c6b2bc18c5b84c3eb47ef",
|
|
"_shrinkwrap": null,
|
|
"_spec": "node-fetch@^1.0.1",
|
|
"_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/isomorphic-fetch",
|
|
"author": {
|
|
"name": "David Frank"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/bitinn/node-fetch/issues"
|
|
},
|
|
"dependencies": {
|
|
"encoding": "^0.1.11",
|
|
"is-stream": "^1.0.1"
|
|
},
|
|
"description": "A light-weight module that brings window.fetch to node.js and io.js",
|
|
"devDependencies": {
|
|
"bluebird": "^3.3.4",
|
|
"chai": "^3.5.0",
|
|
"chai-as-promised": "^5.2.0",
|
|
"codecov": "^1.0.1",
|
|
"form-data": ">=1.0.0",
|
|
"istanbul": "^0.4.2",
|
|
"mocha": "^2.1.0",
|
|
"parted": "^0.1.1",
|
|
"promise": "^7.1.1",
|
|
"resumer": "0.0.0"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==",
|
|
"shasum": "980f6f72d85211a5347c6b2bc18c5b84c3eb47ef",
|
|
"tarball": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz"
|
|
},
|
|
"gitHead": "16f33bf76f06afb58307a652ceb48f597e48a095",
|
|
"homepage": "https://github.com/bitinn/node-fetch",
|
|
"keywords": [
|
|
"fetch",
|
|
"http",
|
|
"promise"
|
|
],
|
|
"license": "MIT",
|
|
"main": "index.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "bitinn",
|
|
"email": "bitinn@gmail.com"
|
|
},
|
|
{
|
|
"name": "timothygu",
|
|
"email": "timothygu99@gmail.com"
|
|
}
|
|
],
|
|
"name": "node-fetch",
|
|
"optionalDependencies": {},
|
|
"readme": "\nnode-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\nA light-weight module that brings `window.fetch` to Node.js\n\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) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side).\n\n\n# Features\n\n- Stay consistent with `window.fetch` API.\n- Make conscious trade-off when following [whatwg fetch spec](https://fetch.spec.whatwg.org/) and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known difference.\n- Use native promise, but allow substituting it with [insert your favorite promise library].\n- Use native stream 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](https://github.com/bitinn/node-fetch/blob/master/ERROR-HANDLING.md) for troubleshooting.\n\n\n# Difference from client-side fetch\n\n- See [Known Differences](https://github.com/bitinn/node-fetch/blob/master/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\n# Install\n\n`npm install node-fetch --save`\n\n\n# Usage\n\n```javascript\nvar fetch = require('node-fetch');\n\n// if you are on node v0.10, set a Promise library first, eg.\n// fetch.Promise = require('bluebird');\n\n// plain text or html\n\nfetch('https://github.com/')\n\t.then(function(res) {\n\t\treturn res.text();\n\t}).then(function(body) {\n\t\tconsole.log(body);\n\t});\n\n// json\n\nfetch('https://api.github.com/users/github')\n\t.then(function(res) {\n\t\treturn res.json();\n\t}).then(function(json) {\n\t\tconsole.log(json);\n\t});\n\n// catching network error\n// 3xx-5xx responses are NOT network errors, and should be handled in then()\n// you only need one catch() at the end of your promise chain\n\nfetch('http://domain.invalid/')\n\t.catch(function(err) {\n\t\tconsole.log(err);\n\t});\n\n// stream\n// the node.js way is to use stream when possible\n\nfetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')\n\t.then(function(res) {\n\t\tvar dest = fs.createWriteStream('./octocat.png');\n\t\tres.body.pipe(dest);\n\t});\n\n// buffer\n// if you prefer to cache binary data in full, use buffer()\n// note that buffer() is a node-fetch only API\n\nvar fileType = require('file-type');\nfetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png')\n\t.then(function(res) {\n\t\treturn res.buffer();\n\t}).then(function(buffer) {\n\t\tfileType(buffer);\n\t});\n\n// meta\n\nfetch('https://github.com/')\n\t.then(function(res) {\n\t\tconsole.log(res.ok);\n\t\tconsole.log(res.status);\n\t\tconsole.log(res.statusText);\n\t\tconsole.log(res.headers.raw());\n\t\tconsole.log(res.headers.get('content-type'));\n\t});\n\n// post\n\nfetch('http://httpbin.org/post', { method: 'POST', body: 'a=1' })\n\t.then(function(res) {\n\t\treturn res.json();\n\t}).then(function(json) {\n\t\tconsole.log(json);\n\t});\n\n// post with stream from resumer\n\nvar resumer = require('resumer');\nvar stream = resumer().queue('a=1').end();\nfetch('http://httpbin.org/post', { method: 'POST', body: stream })\n\t.then(function(res) {\n\t\treturn res.json();\n\t}).then(function(json) {\n\t\tconsole.log(json);\n\t});\n\n// post with form-data (detect multipart)\n\nvar FormData = require('form-data');\nvar form = new FormData();\nform.append('a', 1);\nfetch('http://httpbin.org/post', { method: 'POST', body: form })\n\t.then(function(res) {\n\t\treturn res.json();\n\t}).then(function(json) {\n\t\tconsole.log(json);\n\t});\n\n// post with form-data (custom headers)\n// note that getHeaders() is non-standard API\n\nvar FormData = require('form-data');\nvar form = new FormData();\nform.append('a', 1);\nfetch('http://httpbin.org/post', { method: 'POST', body: form, headers: form.getHeaders() })\n\t.then(function(res) {\n\t\treturn res.json();\n\t}).then(function(json) {\n\t\tconsole.log(json);\n\t});\n\n// node 0.12+, yield with co\n\nvar co = require('co');\nco(function *() {\n\tvar res = yield fetch('https://api.github.com/users/github');\n\tvar json = yield res.json();\n\tconsole.log(res);\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\nReturns a `Promise`\n\n### Url\n\nShould be an absolute url, eg `http://example.com/`\n\n### Options\n\ndefault values are shown, note that only `method`, `headers`, `redirect` and `body` are allowed in `window.fetch`, others are node.js extensions.\n\n```\n{\n\tmethod: 'GET'\n\t, headers: {} // request header. format {a:'1'} or {b:['1','2','3']}\n\t, redirect: 'follow' // set to `manual` to extract redirect headers, `error` to reject redirect\n\t, follow: 20 // maximum redirect count. 0 to not follow redirect\n\t, timeout: 0 // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)\n\t, compress: true // support gzip/deflate content encoding. false to disable\n\t, size: 0 // maximum response body size in bytes. 0 to disable\n\t, body: empty // request body. can be a string, buffer, readable stream\n\t, agent: null // http.Agent instance, allows custom proxy, certificate etc.\n}\n```\n\n\n# License\n\nMIT\n\n\n# Acknowledgement\n\nThanks to [github/fetch](https://github.com/github/fetch) for providing a solid implementation reference.\n\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",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/bitinn/node-fetch.git"
|
|
},
|
|
"scripts": {
|
|
"coverage": "istanbul cover _mocha --report lcovonly -- -R spec test/test.js && codecov",
|
|
"report": "istanbul cover _mocha -- -R spec test/test.js",
|
|
"test": "mocha test/test.js"
|
|
},
|
|
"version": "1.7.3"
|
|
}
|