qlu-fetch
v1.0.11
Published
A fetch wrapper with retries
Downloads
1
Readme
fetch
Getting started
import fetch from 'qlu-fetch'
Call with constant pause time
let res = await fetch('https://randomuser.me/api', {
method: 'GET',
retry: 3,
pause: 1000
})
Call with different pause time for every request
let res = await fetch('https://randomuser.me/api', {
method: 'GET',
retry: 3,
pause: [ 1000, 2000, 3000 ]
})
Options allowed in addition to node-fetch options
retry
: Number
count of retires you wantpause
: Number | Array
Time to dealy between two consecutive retries in case of Arrayretry
must be equal to array.lengthtimeout
: Number
Abort all requests after timeoutsimultaneous
: Boolean
If true retires run simultaneously and return first response
Functions Signature
import { RequestInfo, RequestInit } from "node-fetch"
type RequestOptions = RequestInit & {
retry?: number,
pause?: number | Array<number>,
timeout?: number,
simultaneous?: boolean
}
function fetch(url: RequestInfo, options?: RequestOptions): Promise<Response>