Socket
Socket
Sign inDemoInstall

http-request-retry

Package Overview
Dependencies
53
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http-request-retry

request can retry if fail


Version published
Weekly downloads
8
increased by166.67%
Maintainers
1
Install size
5.13 MB
Created
Weekly downloads
 

Readme

Source

http-request-retry

http-request-retry

  • Config request can retry n time if has error.
  • It has small dependencies include lodash and request.

Install module

npm install http-request-retry --save

Step 1: import module

let httpService = require('http-request-retry');

Step 2: config module

httpService.config({
  debug: false, //log consle if error
  delay: 1000, //waiting time between each retry
});

Step 3: repair options

let options = {
  url: `url request`, // required; url request Ex: http://abc.com https://abc.com
  method: "GET", //required; default POST
  headers: {}, //optional Ex: { 'Content-Type': 'application/json; charset=UTF-8' }
  retry:3,    //optional; type NUMBER
  timeout: 5000, //optional; request timeout; default 60000
};

Step 4: excute

httpService.requestPromise(options).then(res=>{
  console.log(res);
}).catch(err=>{
  console.error(err);
})

Or

httpService.requestCallback(options,(err, result)=>{
  if(err){
    console.log(`Final err`, err);
  }
});

Keywords

FAQs

Last updated on 03 Feb 2019

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