Yet another promising request wrapper.
Promise-based, using the excellent bluebird by default
- Robustness: retry, timeout and connect timeout support
- Proper error handling: All errors (incl. HTTP responses with code >= 400)
throw exceptions, and can be caught with
Promise.catch(). This ensures that all errors are handled, and often cleans up the code by clearly separating out error handling. The
HTTPErrorinstance has all the properties of a normal response.
npm install preq
var preq = ;return preq;
preq-specific parameters / methods
preq passes through most options directly to
request, so see its documentation for
Additionally, it defines or modifies these request options:
method: Lowercase HTTP verbs. Automatically set by the verb methods (
query: query string parameters
Object. If an object is supplied, the serialization depends on the
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.