-
-
Save c0debreaker/3eb3ec1b8721022f0478afd861c54060 to your computer and use it in GitHub Desktop.
GET a bunch of stuff and swallow failures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getAndIgnoreFail = (fn) => { | |
return fn.catch(err => []); | |
}; | |
Promise.all([ | |
getAndIgnoreFail(axios.get('whatever')), | |
getAndIgnoreFail(axios.get('whatever2')), | |
getAndIgnoreFail(axios.get('whatever3')), | |
... | |
]).then(([whatever1, whatever2, whatever3, ...]) => { | |
// do something with your results | |
}).catch(err => { | |
// your error handling... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment