@osskit/fetch-enhancers
v4.4.0
Published
<p align="center"> <img width="350" height="200" src="https://user-images.githubusercontent.com/15312980/175094325-5d4a0459-79e5-4386-ade9-e46d4cef36f2.svg" alt="fetch-enhancers logo"/> </p>
Downloads
20,586
Readme
Bring your own FetchAPI implementation :pray:
Install
yarn add @osskit/fetch-enhancers
Usage
import { withTimeout, withRetry } from '@osskit/fetch-enhancers';
const fetchWithTimeout = withTimeout(fetch, {
requestTimeoutMs: 5000,
}); // *optional* global options 5 seconds timeout
const fetchWithRetry = withRetry(fetch, {
retries: 3,
minTimeout: 1000, // In ms
maxTimeout: 5000, // In ms
factor: 5,
randomize: false,
}); // *optional* global options object is async-retry's options object
// Compose enhancers:
const fetchWithRetryAndTimeout = withRetry(
withTimeout(fetch, {
requestTimeoutMs: 5000,
}),
{
minTimeout: 1000, // In ms
retries: 3,
factor: 5,
},
);