Created
February 17, 2017 17:28
-
-
Save ihgrant/0a9628bc5f26087307bd1109b43a2c84 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