Wednesday, 5 April 2017

Node JS Promise.all() results naming

Is there a way for assigning a name for each result in the Promisee.all?

Let's say this is my code:

Promise.all([getBalls, getKids, getTeams])
.then(function (results) {
    const new_team = doSomething(results[0], results[1],results[2])
    resolve(new_team);
});

And I want it to be something like:

Promise.all([
    balls: getBalls,
    kids: getKids,
    teams: getTeams
]).then(function (results) {
    const new_team = doSomething(balls,kids,teams)
    resolve(new_team);
});



via Hatzav Wolff

No comments:

Post a Comment