Created
November 23, 2019 08:51
-
-
Save YMA-MDL/6b92392819fb717beaec93b0f7491661 to your computer and use it in GitHub Desktop.
Wait for .map to execute #javascript #vanillajs
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 list = [1, 2, 3, 4, 5] //...an array filled with values | |
const functionWithPromise = item => { //a function that returns a promise | |
return Promise.resolve('ok') | |
} | |
const anAsyncFunction = async item => { | |
return functionWithPromise(item) | |
} | |
const getData = async () => { | |
return Promise.all(list.map(item => anAsyncFunction(item))) | |
} | |
getData().then(data => { | |
console.log(data) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment