I am doing 3 $http calls in a factory and I am in troubles.
I declare 4 promises:
var promise = $q.defer(),
PBdeferred = $q.defer(),
Rdeferred = $q.defer(),
Pdeferred = $q.defer();
After that I do the first call to the API
$http.get('/pendingBills').then(function(response) {
var PendingBills = ['id', 'path', 'reservas', 'importe', 'fecha'];
PBdeferred.resolve(PendingBills);
});
And for now resolve the last 2 promises with an empty array (I have not the endopoint yet)
Rdeferred.resolve([]);
Pdeferred.resolve([]);
There is where I use $q.all
$q.all([PBdeferred, Rdeferred, Pdeferred]).then(function (results){
console.log('Results', results);
promise.resolve({
PendingBills: results[0],
Remittances: results[1],
Payed: results[2]
});
});
And return the higth level promise
return promise.promise;
The console log shows the promises but I thougth that in there point the promises are resolved.
Some idea for fix this?