Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify retryWithMergedOptions valid hooks #1832

Merged
merged 5 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions documentation/9-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ await got('https://httpbin.org/status/500', {
(response: Response, retryWithMergedOptions: (options: OptionsInit) => never) => Promisable<Response | CancelableRequest<Response>>
```

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.
PopGoesTheWza marked this conversation as resolved.
Show resolved Hide resolved
> - Calling the `retryWithMergedOptions` function will first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks. Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped.
PopGoesTheWza marked this conversation as resolved.
Show resolved Hide resolved

```js
import got from 'got';
Expand Down
4 changes: 3 additions & 1 deletion source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 first execute any remaining `afterResponse` hooks before triggering `beforeRetry` and possibly `beforeError` hooks.
Meanwhile the `init`, `beforeRequest` , `beforeRedirect` as well as already executed `afterResponse` hooks will be skipped.

@example
```
import got from 'got';
Expand Down