You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
The key has expired.
feat(fetcher): retry middleware (#29)
A new middleware for retrying fetch requests when `response.ok` is
`false`. This middleware was designed to work on a per-endpoint basis.
This means that it should be added immediately after the endpoint
function.
```
import { createApi, requestMonitor, fetcher, fetchRetry } from
'saga-query';
const api = createApi();
api.use(requestMonitor());
api.use(api.routes());
api.use(fetcher());
const fetchUsers = api.get('/users', [
function* (ctx, next) {
// ...
yield next();
// ...
},
fetchRetry(),
])
```
It also supports a backoff function as a parameter. The function
signature is `(attempt: number) => number`, the result of which is how
long to delay the next fetch attempt. If a negative number is provided
then we stop retrying.