1.0.7 • Published 5 years ago
multiple-fetch v1.0.7
multiple-fetch
Make multiple fetch requests and structurize responses.
Installation
# pnpm / npm
pnpm i multiple-fetch isomorhpic-unfetch
# yarn
yarn add multiple-fetch isomorhpic-unfetch
Example
import 'isomorhpic-unfetch'
import multiFetch from 'multifetch'
const urls = ['todos', 'comments']
const results = await multiFetch(
urls,
{
method: 'GET',
headers: {
token: 'lol'
}
},
{ parse: 'json', domain: 'https://jsonplaceholder.typicode.com/' }
)
console.log(results)
/*
{
"results": {
"todos": [...]
},
"errors: [{
"response": {
status: 404,
...
}
"url: "https://jsonplaceholder.typicode.com/comments"
}],
"serverErrors": []
}
*/