Skip to content

Instantly share code, notes, and snippets.

@ihgrant
Created February 17, 2017 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ihgrant/0a9628bc5f26087307bd1109b43a2c84 to your computer and use it in GitHub Desktop.
Save ihgrant/0a9628bc5f26087307bd1109b43a2c84 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