Skip to content

Instantly share code, notes, and snippets.

@ktilcu
Created January 19, 2018 16:37
Show Gist options
  • Select an option

  • Save ktilcu/2e2242c33420a7fe9f99713f3443f59a to your computer and use it in GitHub Desktop.

Select an option

Save ktilcu/2e2242c33420a7fe9f99713f3443f59a to your computer and use it in GitHub Desktop.
Optimal Async example
const getAvatars = async (userId) => {
const user = await getUser(userId);
const avatar = await user.avatar();
const friends = await user.friends();
return [avatar, ...await Promise.all(friends.map(friend => friend.avatar())]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment