Having trouble with 3 $http calls in a factory.
Creating 4 promises:
var promise = $q.defer(),
PBdeferred = $q.defer(),
Rdeferred = $q.defer(),
Pdeferred = $q.defer();
Making the first call to the API:
$http.get('/pendingBills').then(function(response) {
var PendingBills = ['id', 'path', 'reservas', 'importe', 'fecha'];
PBdeferred.resolve(PendingBills);
});
Resolving the last 2 promises with an empty array for now:
Rdeferred.resolve([]);
Pdeferred.resolve([]);
Using $q.all here:
$q.all([PBdeferred, Rdeferred, Pdeferred]).then(function (results){
console.log('Results', results);
promise.resolve({
PendingBills: results[0],
Remittances: results[1],
Payed: results[2]
});
});
Returning the top-level promise:
return promise.promise;
The console log displays the promises, but I expected them to be resolved at this point.
Any ideas on how to fix this?