{"name":"req-then","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"0.5.1","description":"Simple http(s) request function, returning a promise. ","repository":{"type":"git","url":"git+https://github.com/75lb/req-then.git"},"main":"index","bin":{"req-then":"bin/cli.js"},"license":"MIT","keywords":["http","https","request","promise","then","req","es6","native"],"engines":{"node":">=0.10.0"},"scripts":{"test":"test-runner test/*.js","docs":"jsdoc2md -t jsdoc2md/README.hbs lib/*.js -l js > README.md; echo","start":"node test/interactive/server.js","es5":"rm -rf es5 && babel --presets babel-preset-es2015 --no-comments lib --out-dir es5"},"dependencies":{"array-back":"^1.0.3","defer-promise":"^1.0.0","feature-detect-es6":"^1.3.1","lodash.pick":"^4.4.0","typical":"^2.6.0"},"devDependencies":{"babel-preset-es2015":"^6.18.0","jsdoc-to-markdown":"^2.0.1","test-runner":"^0.2.5"},"standard":{"ignore":["es5"]},"gitHead":"eab6393cf04c87897a36982517c07e6580d604c6","bugs":{"url":"https://github.com/75lb/req-then/issues"},"homepage":"https://github.com/75lb/req-then#readme","_id":"req-then@0.5.1","_shasum":"31c6e0b56f4ddd2acd6de0ba1bcea77b6079dfdf","_from":".","_npmVersion":"3.10.8","_nodeVersion":"7.0.0","_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"dist":{"shasum":"31c6e0b56f4ddd2acd6de0ba1bcea77b6079dfdf","tarball":"http://registry-npm.ywwl.com/req-then/download/req-then-0.5.1.tgz","integrity":"sha512-ald8dmP4zgF87wWs1n+/TppCd9LB6zZfAWSqF/RFCQ/ImDoH6ro77vmfOLhwkgH2uB8mcn4fNbwL9DEbpKCwJA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID1KbZiSvc8b+brPoVfDBusOKVmiqhZapyuCQkRAYLJWAiEAqzp03X/tjR0MRZ0W4KrJR8EatkGyMvDCVkIZB+n+Ubo="}],"size":4447,"noattachment":false,"key":"/req-then/-/req-then-0.5.1.tgz"},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/req-then-0.5.1.tgz_1478036146901_0.6152960355393589"},"directories":{},"readme":"[![view on npm](http://img.shields.io/npm/v/req-then.svg)](https://www.npmjs.org/package/req-then)\n[![npm module downloads](http://img.shields.io/npm/dt/req-then.svg)](https://www.npmjs.org/package/req-then)\n[![Dependency Status](https://david-dm.org/75lb/req-then.svg)](https://david-dm.org/75lb/req-then)\n[![Coverage Status](https://coveralls.io/repos/github/75lb/req-then/badge.svg)](https://coveralls.io/github/75lb/req-then)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n<a name=\"module_req-then\"></a>\n\n## req-then\nWraps node's built-in http(s) `request` function with a few extras:\n\n- Returns a promise, resolving to an object containing the data, node response and original request.\n- Automatically selects `http` or `https` transport depending on the input URL.\n- Cancellable (which `fetch` is not).\n\n**Example**  \n```js\nconst request = require('req-then')\n\nrequest('http://www.bbc.co.uk')\n  .then(response => {\n    console.log('Response data received', response.data)\n    console.log('The original request options', response.req)\n    console.log('The nodejs response instance', response.res)\n  })\n  .catch(console.error)\n```\n**Example**  \n```js\nconst request = require('req-then')\nconst url = require('url')\nconst reqOptions = url.parse('http://www.bbc.co.uk')\nconst controller = {}\nreqOptions.controller = controller\nrequest(reqOptions)\n  .then(response => {\n    console.log('Response data received', response.data)\n  })\n\n// kill the request and close the socket\ncontroller.abort()\n```\n<a name=\"exp_module_req-then--request\"></a>\n\n### request(reqOptions, [data]) ⇒ <code>external:Promise</code> ⏏\nReturns a promise for the response.\n\n**Kind**: Exported function  \n**Resolve**: <code>object</code> - `res` will be the node response object, `data` will be the data, `req` the original request.  \n**Reject**: <code>Error</code> - If aborted, the `name` property of the error will be `aborted`.  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| reqOptions | <code>string</code> \\| <code>object</code> | Target url string or a standard node.js http request options object. |\n| [reqOptions.controller] | <code>object</code> | If supplied, an `.abort()` method will be created on it which, if invoked, will cancel the request. Cancelling will cause the returned promise to reject with an `'aborted'` error. |\n| [data] | <code>\\*</code> | Data to send with the request. |\n\n\n* * *\n\n&copy; 2015-17 Lloyd Brookes \\<75pound@gmail.com\\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","publish_time":1478036148664,"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","_cnpm_publish_time":1478036148664,"dist-tags":{"latest":"0.6.4"}}