Skip to content

Instantly share code, notes, and snippets.

@nikolasrangel
Created November 8, 2018 15:10
Show Gist options
  • Save nikolasrangel/bdf27033632928c51ccbbe953e4967bf to your computer and use it in GitHub Desktop.
Save nikolasrangel/bdf27033632928c51ccbbe953e4967bf to your computer and use it in GitHub Desktop.
async/await inside .map()
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