Created
April 20, 2017 21:33
-
-
Save johhansantana/34527288cd75ef0a32d5f60d685f2f46 to your computer and use it in GitHub Desktop.
Run multiple async/await functions simultaneously
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
async () => { | |
try { | |
const [locations, categories] = await Promise.all([ | |
getLocations(), | |
getCategories() | |
]) | |
this.setState({locations, categories, loading: false}); | |
} catch (err) { | |
alert("Error: " + err.code + " " + err.message); | |
this.setState({loading: false}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment