1
I need to get the values of some Apis.
For example: calls to api1()
and api2()
return deferred.promise
;
I can do:
api1().then( function(res1){
api2().then( function(res2){
console.log(res1, res2);
})
});
How can I improve these calls to Apis using Q Promises?
I tried to use something like: Q.fcall(api1()).then(api2())
...
Take a look here: http://answall.com/a/137828/129, I think that’s what you want. In your case it would be
Q.all([api1(),api2()]).then(function(res){console.log(res[0],res[1]); });
. Test and tell if it works with the apiQ.js
.– Sergio