Skip to content

Instantly share code, notes, and snippets.

@c0debreaker
Forked from ihgrant/example.js
Last active February 17, 2017 17:46
Show Gist options
  • Save c0debreaker/3eb3ec1b8721022f0478afd861c54060 to your computer and use it in GitHub Desktop.
Save c0debreaker/3eb3ec1b8721022f0478afd861c54060 to your computer and use it in GitHub Desktop.
GET a bunch of stuff and swallow failures
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