fetchx
v2.9.0
Published
fetch extended
Downloads
2
Readme
fetchx
Add some extra options to fetch
add timeout
let url = 'http://httpbin.org/delay/10'
fetchx(url, {timeout:3000})
.catch(e => {
assert.equal(e, 'timeout')
})
change url's protocol and host
let url = 'https://no-such-host.com/status/200'
fetchx(url, {forceServer: 'http://httpbin.org'})
.then(resp => {
assert.equal(resp.status, 200)
assert.equal(resp.url, 'http://httpbin.org')
})
provide fallback servers
let url = 'https://no-such-host.com/status/200'
fetchx(url, {fallbackServers: ['http://another-no-such-host.com', 'http://httpbin.org']})
.then(resp => {
assert.equal(resp.status, 200)
assert.equal(resp.url, 'http://httpbin.org/status/200')
})