Skip to content

Instantly share code, notes, and snippets.

@escaroda
Created April 6, 2018 07:34
Show Gist options
  • Save escaroda/382f9f69def2f1ad28866a87efdfa213 to your computer and use it in GitHub Desktop.
Save escaroda/382f9f69def2f1ad28866a87efdfa213 to your computer and use it in GitHub Desktop.
js promise - good practice
// bad
async function someAsyncFunc() {
const user = await asyncGetUser();
const categories = await asyncGetCategories();
const mapping = await asyncMapUserWithCategory(user, categories);
}
// good
async function someAsyncFunc() {
const [user, categories] = await Promise.all([
asyncGetUser(),
asyncGetCategories()
]);
const mapping = await asyncMapUserWithCategory(user, categories);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment