I have two Promises (let's say p
and q
) that will retrieve data when resolved, and I want to do something foo
that needs the both data. It has a solution as coded below. But is there a more elegant one?
p.then(pData => {
q.then(qData => {
foo(pData,qData);
});
});
I was wondering something like follows (hypothetical function and
):
p.and(q).then(dataArr => foo( ...dataArr ));
In the case there's no such way, is there anything in the promises concept that would disallow this construction?