I am dealing with 6 asynchronous requests. The problem I'm facing is that if one of them encounters an error and returns a 404 status code, the other requests stop functioning as well. I have implemented the use of async.parallel
to handle these requests, but unfortunately, I haven't been able to get it to work properly.
Below is the snippet of my code:
async.parallel({
request1: async (callback) => {
const [err, result] = await to(this.$store.dispatch('myAction1', {
id: this.$route.params.id,
}));
callback(err, result);
},
// Code for request2 to request6 omitted for brevity
}, (err, results) => {
if (err) {
// Display an error message when any request fails
}
// Perform actions when all requests are successful and hide the page loader.
this.hidePageLoader();
});
The issue is that even if one of the requests returns a 404 error, the page loader still shows up. My goal is to either pass a failed request as null
in the results
object or return the other results without including the failed request in the results
object. How can I achieve this correctly?