Skip to content

Instantly share code, notes, and snippets.

@leefsmp
Last active October 30, 2016 17:54
Show Gist options
  • Save leefsmp/77125ad32b43896388872aa149244c30 to your computer and use it in GitHub Desktop.
Save leefsmp/77125ad32b43896388872aa149244c30 to your computer and use it in GitHub Desktop.
async function getItem (id) {
var response = await fetch('/api/items/' + id)
var item = await response.json()
return item
}
async function taskOnItems (itemIds) {
const itemTasks = itemIds.map((id) => {
return getItem(id)
})
const items = await Promise.all(itemTasks)
//All items retrieved
items.forEach((item) => {
console.log('Item: ' + item.name)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment