You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constRequestRetry=require('request-retry');constWreck=require('wreck');// Or your HTTP client library of choice(async()=>{constyourRegularFunc=async()=>{constoptions={timeout: 1000};returnawaitWreck.get('https://httpbin.org/delay/5',options);};constretry=newRequestRetry();retry.events.on('failedAttempt',(data)=>console.log('Failed attempt: '+data.attemptNumber));awaitretry.run(yourRegularFunc);// Makes 3 calls, then rejects with a timeout error})();
Example 2
constRequestRetry=require('request-retry');constWreck=require('wreck');// Or your HTTP client library of choice(async()=>{constyourRegularFunc=async()=>{returnawaitWreck.get('https://httpbin.org/status/502');};constoptions={numberOfRetries: 4,waitBetweenFirstRetryInMilliseconds: 2000};constretry=newRequestRetry(options);retry.events.on('failedAttempt',(data)=>console.log('Failed attempt: '+data.attemptNumber));awaitretry.run(yourRegularFunc);// Makes 5 calls, then rejects with a Bad Gateway error})();