Socket
Socket
Sign inDemoInstall

node-request-retry

Package Overview
Dependencies
47
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-request-retry

A simple Node.js request wrapper for retrying http requests.


Version published
Weekly downloads
26
increased by2500%
Maintainers
1
Install size
3.80 MB
Created
Weekly downloads
 

Readme

Source

node-request-retry

A simple Node.js request wrapper for retrying http requests.

Usage
var RequestRetry = require('node-request-retry');

var requestRetry = new RequestRetry();

var retryConditions = [];
// Retries can be triggered by either receiving a certain status code
Array.prototype.push.apply(retryConditions, [400, 404, 408, 500]);

// ... or by evaluating a function. Returning true means the request should be retried.
var fnShouldRetry = function(response, body) {
  if (body == false)
    return true;
  else
    return false;
};
retryConditions[retryConditions.length] = fnShouldRetry;

requestRetry.setRetryCodes(retryConditions);

// POST
requestRetry.post(url, postData, function(err, response, body) {
  /* ... */
});
Modify Defaults
var RequestRetry = require('node-request-retry');

// A wrapper for request.defaults(obj);
RequestRetry.setDefaults({timeout: 30000});

// Default is 3
Request.setMaxRetries(5);

// Default is 10000
Request.setRetryDelay(20000);

FAQs

Last updated on 03 Feb 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc