Socket
Socket
Sign inDemoInstall

req-then

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

req-then - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

4

es5/req-then.js

@@ -20,6 +20,2 @@ 'use strict';

if (data && !reqOptions.headers['content-length']) {
reqOptions.headers['content-length'] = data.length;
}
var deferred = defer();

@@ -26,0 +22,0 @@

21

lib/req-then.js

@@ -13,3 +13,2 @@ 'use strict'

* - Returns a promise, resolving to an object containing the data, node response and original request.
* - If data was supplied, sets a `content-length` header if not already present.
* - Automatically selects `http` or `https` transport depending on the input URL.

@@ -24,6 +23,20 @@ * - Cancellable (which `fetch` is not).

* .then(response => {
* console.log('Response received', response.data)
* console.log('Response data received', response.data)
* console.log('The original request options', response.req)
* console.log('The nodejs response instance', response.res)
* })
* .catch(console.error)
* @example
* const request = require('req-then')
* const url = require('url')
* const reqOptions = url.parse('http://www.bbc.co.uk')
* const controller = {}
* reqOptions.controller = controller
* request(reqOptions)
* .then(response => {
* console.log('Response data received', response.data)
* })
*
* // kill the request and close the socket
* controller.abort()
*/

@@ -50,6 +63,2 @@ module.exports = request

if (data && !reqOptions.headers['content-length']) {
reqOptions.headers['content-length'] = data.length
}
const deferred = defer()

@@ -56,0 +65,0 @@

{
"name": "req-then",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "0.4.1",
"version": "0.5.0",
"description": "Simple http(s) request function, returning a promise. ",

@@ -36,8 +36,8 @@ "repository": "https://github.com/75lb/req-then",

"lodash.pick": "^4.4.0",
"typical": "^2.5.0"
"typical": "^2.6.0"
},
"devDependencies": {
"babel-preset-es2015": "^6.13.2",
"babel-preset-es2015": "^6.14.0",
"jsdoc-to-markdown": "^2.0.0-alpha.11"
}
}

@@ -12,3 +12,2 @@ [![view on npm](http://img.shields.io/npm/v/req-then.svg)](https://www.npmjs.org/package/req-then)

- Returns a promise, resolving to an object containing the data, node response and original request.
- If data was supplied, sets a `content-length` header if not already present.
- Automatically selects `http` or `https` transport depending on the input URL.

@@ -23,3 +22,4 @@ - Cancellable (which `fetch` is not).

.then(response => {
console.log('Response received', response.data)
console.log('Response data received', response.data)
console.log('The original request options', response.req)
console.log('The nodejs response instance', response.res)

@@ -29,2 +29,17 @@ })

```
**Example**
```js
const request = require('req-then')
const url = require('url')
const reqOptions = url.parse('http://www.bbc.co.uk')
const controller = {}
reqOptions.controller = controller
request(reqOptions)
.then(response => {
console.log('Response data received', response.data)
})
// kill the request and close the socket
controller.abort()
```
<a name="exp_module_req-then--request"></a>

@@ -31,0 +46,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc