Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Yet another promising request wrapper.
Promise
-based, using the excellent
bluebird by
defaultPromise.catch()
. This ensures
that all errors are handled, and often cleans up the code by clearly
separating out error handling. The HTTPError
instance has all the
properties of a normal response.npm install preq
var preq = require('preq');
return preq.get({ // or preq.request({ method: 'get', .. })
uri: 'http://google.com/',
headers: {
'x-foo': 'bar'
},
query: {
q: 'foo'
},
// body for POSTs or PUTs, can be object (serialized to JSON), Buffer or String
})
.then(function(res) {
/**
* {
* status: 200,
* headers: {
* date: 'Sat, 21 Feb 2015 01:47:40 GMT' // , ...
* },
* body: '<!doctype html>...</html>' // or object if json
* }
*/
})
.catch(function(err) {
// Any response with HTTP status >= 400
// err is HTTPError with same properties as response above
});
preq
-specific parameters / methodspreq
passes through most options directly to
request, so see its documentation for
advanced options.
Additionally, it defines or modifies these request options:
method
: Lowercase HTTP verbs. Automatically set by the verb methods (preq.get()
,
.post()
etc).uri
: use uri
, not url
.query
: query string parametersbody
: String
, Buffer
or Object
. If an object is supplied, the
serialization depends on the content-type
header. Supported:
application/json.*
multipart/form-data
application/x-www-form-urlencoded
retries
: Maximum number of retries. Exponential back-off is used between retries.timeout
: Total request timeout.The connection timeout, maximum time to establish a TCP connection to the host is 5 seconds by default
and can be altered with PREQ_CONNECT_TIMEOUT
environment variable.
Also see the tests for usage examples.
FAQs
Yet another promising request wrapper
We found that preq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.