Skip to content

Commit

Permalink
Merge 54e367d into 85b052f
Browse files Browse the repository at this point in the history
  • Loading branch information
batmat committed Jul 17, 2018
2 parents 85b052f + 54e367d commit 0b5cc40
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ const logger = require('./modules/logger')('request-promise-retry');

class rpRetry {
static _rpRetry(options) {
logger.info(`calling ${options.uri} with retry ${options.retry}`);
if(options.verboseLogging) {
logger.info(`calling ${options.uri} with retry ${options.retry}`);
}
const tries = options.retry || 1;
delete options.retry;
const fetchDataWithRetry = tryCount => {
return requestPromise(options)
.then(result => {
logger.info(`Result obtained for ${options.method} request to ${options.uri}`);
if(options.verboseLogging) {
logger.info(`Result obtained for ${options.method} request to ${options.uri}`);
}
return Promise.resolve(result);
})
.catch(err => {
Expand All @@ -27,10 +31,14 @@ class rpRetry {
}

static _rp(options) {
logger.info(`calling ${options.uri} without retries`);
if(options.verboseLogging) {
logger.info(`calling ${options.uri} without retries`);
}
return requestPromise(options)
.then(result => {
logger.info(`Result obtained for ${options.method} request to ${options.uri}`);
if(options.verboseLogging) {
logger.info(`Result obtained for ${options.method} request to ${options.uri}`);
}
return Promise.resolve(result);
})
.catch(err => {
Expand Down

0 comments on commit 0b5cc40

Please sign in to comment.