Skip to content

Instantly share code, notes, and snippets.

@russiann
Last active September 10, 2016 21:52
Show Gist options
  • Save russiann/c7d062798ccd1405e6443b3893bd0ae6 to your computer and use it in GitHub Desktop.
Save russiann/c7d062798ccd1405e6443b3893bd0ae6 to your computer and use it in GitHub Desktop.
Promise.all with Map
const ids = [1,2,3,4,5,6];
const fetchData = (id) => {
httpLib.get(`http://whatever.com/api/${id}`, (res) => {
resolve(id)
});
}
Promise.all(ids.map(fecthData))
.then(responses => {
// responses will be a array with each response
// to stuff
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment