Last active
September 10, 2016 21:52
-
-
Save russiann/c7d062798ccd1405e6443b3893bd0ae6 to your computer and use it in GitHub Desktop.
Promise.all with Map
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
| 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