another-rest-client icon indicating copy to clipboard operation
another-rest-client copied to clipboard

💡Can you add retry config to your amazing work?

Open jechaviz opened this issue 2 years ago • 0 comments

Just like this (maybe like your awesome fluent api) In this project: https://github.com/JustinBeckwith/retry-axios and add methods like get, put, and so on doing their job. source: https://github.com/JustinBeckwith/retry-axios `raxConfig: { // Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3. retry: 3,

// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
noResponseRetries: 2,

// Milliseconds to delay at first.  Defaults to 100. Only considered when backoffType is 'static'
retryDelay: 100,

// HTTP methods to automatically retry.  Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],

// The response status codes to retry.  Supports a double
// array with a list of ranges.  Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [429, 429], [500, 599]],

// If you are using a non static instance of Axios you need
// to pass that instance here (const ax = axios.create())
instance: ax,

// You can set the backoff type.
// options are 'exponential' (default), 'static' or 'linear'
backoffType: 'exponential',

// You can detect when a retry is happening, and figure out how many
// retry attempts have been made
onRetryAttempt: err => {
  const cfg = rax.getConfig(err);
  console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
}

}`

Also there's another that has it's magic hidden like this: https://github.com/softonic/axios-retry

Thanks in advance beacuse your awesome work

jechaviz avatar Apr 25 '22 20:04 jechaviz