Type alias RetryMiddleware

RetryMiddleware: ((options?: RetryOptions) => ConfiguredMiddleware)

Type declaration

    • (options?: RetryOptions): ConfiguredMiddleware
    • Retry middleware

      Retries a request multiple times in case of an error (or until a custom condition is true).

      Options

      • delayTimer milliseconds

      The timer between each attempt.

      (default: 500)

      • delayRamp (delay, nbOfAttempts) => milliseconds

      The custom function that is used to calculate the actual delay based on the the timer & the number of attemps.

      (default: delay * nbOfAttemps)

      • maxAttempts number

      The maximum number of retries before resolving the promise with the last error. Specifying 0 means infinite retries.

      (default: 10)

      • until (response, error) => boolean || Promise<boolean>

      The request will be retried until that condition is satisfied.

      (default: response && response.ok)

      • onRetry ({ response, error, url, options }) => { url?, options? } || Promise<{url?, options?}>

      Callback that will get executed before retrying the request. If this function returns an object having url and/or options properties, they will override existing values in the retried request.

      (default: null)

      • retryOnNetworkError boolean

      If true, will retry the request if a network error was thrown. Will also provide an 'error' argument to the onRetry and until methods.

      (default: false)

      Parameters

      Returns ConfiguredMiddleware

Generated using TypeDoc