diff --git a/documentation/9-hooks.md b/documentation/9-hooks.md index 9bda9bba9..e3ead6429 100644 --- a/documentation/9-hooks.md +++ b/documentation/9-hooks.md @@ -218,13 +218,14 @@ await got('https://httpbin.org/status/500', { (response: Response, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable> ``` +Each function should return the response. This is especially useful when you want to refresh an access token. + **Note:** > - When using the Stream API, this hook is ignored. **Note:** -> - Calling the retry function will trigger `beforeRetry` hooks. - -Each function should return the response. This is especially useful when you want to refresh an access token. +> - Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead. +Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. ```js import got from 'got'; diff --git a/source/core/options.ts b/source/core/options.ts index dfbe8ab9d..7c070cf78 100644 --- a/source/core/options.ts +++ b/source/core/options.ts @@ -186,13 +186,15 @@ export interface Hooks { /** Called with [response object](#response) and a retry function. - Calling the retry function will trigger `beforeRetry` hooks. Each function should return the response. This is especially useful when you want to refresh an access token. __Note__: When using streams, this hook is ignored. + __Note__: Calling the `retryWithMergedOptions` function will trigger `beforeRetry` hooks. If the retry is successful, all remaining `afterResponse` hooks will be called. In case of an error, `beforeRetry` hooks will be called instead. + Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped. + @example ``` import got from 'got';