Skip to content

Commit 930a3e6

Browse files
author
Dan Klco
committed
Adding documentation for providing fetch
1 parent 3fab3f9 commit 930a3e6

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ All the retry options are configurable and can be set in `retryOptions` in the `
6262
| `retryOnHttpError` | Function | a *function* determining whether to retry given the HTTP error exception thrown. Can be asynchronous | none | retry on all `FetchError`'s of type `system`|
6363
| `socketTimeout` | Number | time until socket timeout in milliseconds. _Note: if `socketTimeout` is >= `retryMaxDuration`, it will automatically adjust the socket timeout to be exactly half of the `retryMaxDuration`. To disable this feature, see `forceSocketTimeout` below_ | `NODE_FETCH_RETRY_SOCKET_TIMEOUT` | 30000 ms |
6464
| `forceSocketTimeout` | Boolean | If true, socket timeout will be forced to use `socketTimeout` property declared regardless of the `retryMaxDuration`. _Note: this feature was designed to help with unit testing and is not intended to be used in practice_ | `NODE_FETCH_RETRY_FORCE_TIMEOUT` | false |
65+
| `fetch` | Function | the fetch API implementation to use | none |
66+
| `AbortController` | Function | the AbortController constructor function to use | none |
6567

6668
_Note: the environment variables override the default values if the corresponding parameter is not set. These are designed to help with unit testing. Passed in parameters will still override the environment variables_
6769

@@ -162,6 +164,23 @@ async main() {
162164
}
163165
```
164166

167+
### Custom Fetch
168+
169+
You can disable all retry behavior by setting `retryOptions` to `false`.
170+
171+
```js
172+
const {fetch: adobeFetch, AbortController} = require('@adobe/fetch');
173+
const fetch = require('@adobe/node-fetch-retry');
174+
175+
async main() {
176+
const response = await fetch(url, {
177+
retryOptions: false,
178+
fetch: adobeFetch,
179+
AbortController
180+
});
181+
}
182+
```
183+
165184
Disabling retry behavior will not prevent the usage of other options set on the `options` object.
166185

167186
### Additional notes on retry duration

0 commit comments

Comments
 (0)