Skip to content

Instantly share code, notes, and snippets.

@ngohuytrieu
Last active April 9, 2022 08:57
Show Gist options
  • Save ngohuytrieu/6a81d18fe876191875a17ed5c2947908 to your computer and use it in GitHub Desktop.
Save ngohuytrieu/6a81d18fe876191875a17ed5c2947908 to your computer and use it in GitHub Desktop.
Run async/await in javascript event functions
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