Created
January 19, 2018 16:37
-
-
Save ktilcu/2e2242c33420a7fe9f99713f3443f59a to your computer and use it in GitHub Desktop.
Optimal Async example
This file contains hidden or 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 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