Created
August 31, 2017 18:10
-
-
Save andrIvash/d22a4c35ffb634af9f40acb238780b48 to your computer and use it in GitHub Desktop.
Array of promises
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
| function fetchUserDetails(arr) { | |
| return arr.reduce(function(promise, elem) { | |
| return promise.then(function() { | |
| return db.getUser(email).done(function(res) { | |
| logger.log(res); | |
| }); | |
| }); | |
| }, Promise.resolve()); | |
| } | |
| var arrayOfEmailAddys = []; | |
| fetchUserDetails(arrayOfEmailAddys).then(function() { | |
| console.log('all done'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment