diff --git a/README.md b/README.md index 5bf3076..001275a 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ client | retryDelay | `Function` | `function noDelay() { return 0; }` | A callback to further control the delay in milliseconds between retried requests. By default there is no delay between retries. Another option is exponentialDelay ([Exponential Backoff](https://developers.google.com/analytics/devguides/reporting/core/v3/errors#backoff)). The function is passed `retryCount` and `error`. | | onRetry | `Function` | `function onRetry(retryCount, error, requestConfig) { return; }` | A callback to notify when a retry is about to occur. Useful for tracing and you can any async process for example refresh a token on 401. By default nothing will occur. The function is passed `retryCount`, `error`, and `requestConfig`. | | onMaxRetryTimesExceeded | `Function` | `function onMaxRetryTimesExceeded(error, retryCount) { return; }` | After all the retries are failed, this callback will be called with the last error before throwing the error. | +| validateResponse | `Function | null` | `null` | A callback to define whether a response should be resolved or rejected. If null is passed, it will fallback to the axios default (only 2xx status codes are resolved). | ## Testing diff --git a/src/index.ts b/src/index.ts index 89139a6..5b72857 100644 --- a/src/index.ts +++ b/src/index.ts @@ -41,7 +41,8 @@ export interface IAxiosRetryConfig { */ onMaxRetryTimesExceeded?: (error: AxiosError, retryCount: number) => Promise | void; /** - * Defines whether a response should be resolved or rejected + * A callback to define whether a response should be resolved or rejected. If null is passed, it will fallback to + * the axios default (only 2xx status codes are resolved). */ validateResponse?: ((response: AxiosResponse) => boolean) | null; }