Last active
October 30, 2016 17:54
-
-
Save leefsmp/77125ad32b43896388872aa149244c30 to your computer and use it in GitHub Desktop.
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
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