I'm using the request-promise module and have found no mention of how to chain requests. I'm currently following their syntax of:
request({options})
.then(function(result){...})
.catch(function(error){...})
However I want to be able to use Promise.all and try to make multiple calls at the same time and wait for them to all resolve and then proceed with other calls. For example I want to:
- Make a call to one app creating a User.
- AT THE SAME TIME, make a call creating an Address.
- Promise.all([UserCall, AddressCall]).then({function to deal with results])?
Also I have been working with my function in module.exports = {...}. Does this require me to be outside of exports and have them declare as separate variables?
From what I understand its seems as if I have to do something like:
var UserCall = function(req,res){
return new Promise(function (resolve, reject){
request({options})? //To make the call to create a new user?
// Then something with resolve and reject
Any help is much appreciated. I think I may be mixing up basic BlueBird concepts and trying to use them with request-promise.