I need to keep sending http requests until I receive an error 404 response from one of them.
There are a total of 21 pages and my current setup looks like this:
_getAll = function () {
var promises = [];
var pages = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21];
angular.forEach(pages, function (page) {
var deffered = $q.defer();
$http({
url: 'http://api.tvmaze.com/shows?page=' + page,
method: 'GET'
}).
success(function (data) {
console.log("OK")
deffered.resolve(data);
}).
error(function (error) {
deffered.reject(error);
console.log(error.status);
});
promises.push(deffered.promise)
})
return $q.all(promises);
},
However, when trying to access , it returns a 404 error
.
Is there a way to continue making http
requests until a 404
response is received? Whether through looping or another method?