Loop through items, awaiting a promise return for each item.
This file contains 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 myFunc(items){ | |
var fn = function addSomethingToItem(item){ | |
return new Promise(resolve => { | |
myFirstActionFunc() | |
.then( response =>{ | |
item.value = response; | |
resolve(item); | |
}) | |
.catch(err => reject(err)); | |
}); | |
}; | |
var actions = items.map(fn); | |
var results = Promise.all(actions); | |
return new Promise( (resolve,reject) =>{ | |
results.then(data =>{ | |
return resolve(data); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment