I am trying to make server get requests concurrently, in order to do that I have written the following function.
Problem
If a single call is failing then I am not able to get the response of rest of the requests.
export const getAll = async (collection) => {
return new Promise((resolve, reject) => {
const requests = collection.map(req => {
const config = {
headers: req.headers,
params: req.params
}
return axios.get(req.url, config);
})
axios.all(requests)
.then(axios.spread((...args) => {
// all succerss
resolve(args);
}))
.catch(function (error) {
// single call fails and all calls are lost
reject(error)
});
})
}
Is it possible to get the result of all requests whether it fails or success?