Last active
April 9, 2022 08:57
-
-
Save ngohuytrieu/6a81d18fe876191875a17ed5c2947908 to your computer and use it in GitHub Desktop.
Run async/await in javascript event functions
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 data = [] | |
// using promise.all | |
const data = await Promise.all(data.map(async (item, index) => { | |
// call async function here | |
item.products = await asyncawaitfunction() | |
return item | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment