Reputation: 2053
I have the following snippet in my code which set a timeout in milliseconds for the request.But its not cancelled even if the timeout is met.
var httpURL = {
method : URLobj.method,
url : urlString,
data : data,
withCredentials : true,
headers : URLobj.headers,
timeout:200
};
this.$http(httpURL).success(successFunc).error(errorFunc);
Can someone please shed some light on how this timeout parameter can be used.I am using v1.2.26.
Upvotes: 3
Views: 9976
Reputation: 283
Below syntax will works
$http.post(url, parms, {timeout: 60000}).then(function(success){}, function(error){})
Upvotes: -1
Reputation: 2053
I had config.timeout = deferred.promise; in one of my interceptor which had overridden the value that i have set. Commenting it out worked for me.
config.timeout = deferred.promise;
Upvotes: 1
Reputation: 2599
This would be how you create a $http call with a timeout
$http({
method: URLobj.method,
url: urlstring,
withCredentials : true,
headers: URLobj.headers,
timeout: 200
}).success(function(data){
// With the data succesfully returned, call our callback
successFunc(data);
}).error(function(){
errorFunc("error");
});
}
});
Upvotes: 3