Created
November 8, 2018 15:10
-
-
Save nikolasrangel/bdf27033632928c51ccbbe953e4967bf to your computer and use it in GitHub Desktop.
async/await inside .map()
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 asyncFunction = async (arr) => { | |
const arrOfPromises = arr.map(async param => { | |
const response = await fetch(`/api/${param}`); | |
return response.json(); | |
}); | |
const result = await Promise.all(arrOfPromises); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment