我使用的是角度$http.post
请求,我的响应是在接近5-8 min
之后,所以天使在这里失败了,因为当响应不是在特定的时间,而不是它发送回第二次请求时,我们如何设置请求响应的时间来等待?
发布于 2015-04-07 06:57:57
$http中有一个超时属性,您可以使用它。
下面使用get
的示例
app.run(function($http, $q, $timeout){
var deferred = $q.defer();
$http.get('/path/to/api', { timeout: deferred.promise })
.then(function(){
// success handler
},function(reject){
// error handler
if(reject.status === 0) {
// $http timeout
} else {
// response error status from server
}
});
$timeout(function() {
deferred.resolve(); // this aborts the request!
}, 1000);
});
在文档中阅读更多关于它的信息
https://stackoverflow.com/questions/29485593
复制相似问题