If I have multiple fetch()
calls within a Promise.all
block, when one fails, it all fails. That's cool, I need them all to resolve.
However, how can I find which one actually failed?
In the following code, the catch error
tells me:
TypeError: Failed to fetch`
which makes it impossible to construct an effective user error message should I choose to do so.
const goodUrl = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js';
const badUrl = 'https://ajax.googleapis77.com/ajax/libs/jquery/2.1.3/jquery.min.js';
Promise.all([
fetch(goodUrl),
fetch(badUrl), /* will fail */
fetch(goodUrl)
]).then(([response1, response2, response3]) => {
console.log(response1);
console.log(response2);
console.log(response3);
}).catch((err) => {
console.log(err);
});
Here's a fiddle (a snippet didn't play nice)
I have looked for duplicates, this is not one as the examples throw the same error