Within my JavaScript function, I am utilizing rest calls and the responses to construct the payload for subsequent calls. Included below is some pseudo code exemplifying my approach. Although my code is currently functional, I am unsure how to properly return the promise p3 to the updateList caller. Any guidance on this matter would be greatly appreciated. Thank you.
function updateList(listOfUsers){
var p1 = getUser(userId1); // returns a promise
var p2 = getUser(userId2); // returns a promise
$q.all([p1, p2]).then(function success(){
...some code to get the users and build payload for next call...
var p3 = updateList(payload); //also returns a promise
//how do I return p3?
});
}
-dj