I am doing custom $http service that looks something like this:
angular.factory('myHttp', function($http){
var obj = {};
obj.get = function(path) {
return $http.get(path,{timeout: 5000}).error(function (result) {
console.log("retrying");
return obj.get(path);
});
}
});
The system works fine. It does return the data when success, and retrying when connection fail. However, I am facing problem that it will return to controller when the connection is timeout. How can I prevent it from returning and continue retrying?
$httpfeature.myHttp.get($scope.url).success(function(response) {});Any advice to get it works?return obj.get(path);The logic works and it will retrying even when it is timeout. The problem is when it is timeout, it will not wait for retrying and returning.....then(null, errorCallback)instead oferror. Usingthenyou can return a promise, but not with usingerror.erroris deprecated anyway and shouldn't be used anymore.myHttp.get('url').then(successCallback, errorCallback), even if the service return a fail connection, it will return tosuccessCallbacknoterrorCallback. How can I make it toerrorCallback?