[英]AngularJS HTTP error codes with $q.all()?
I have a bunch of http requests like this: 我有一堆这样的http请求:
$q.all([$http({
method: 'POST',
url: urlOne,
headers: {Authorization: "Token " + jqToken}
}), $http({
method: 'POST',
url: urlTwo,
headers: {Authorization: "Token " + jqToken}
})])
.then(function (results) {
//do stuff
});
However urlOne and urlTwo (and a bunch of others) may under some conditions return 403. In this case everything just freezes and then() function is never executed. 但是,在某些情况下urlOne和urlTwo(以及其他一堆)可能会返回403。在这种情况下,所有内容都将冻结,并且then()函数将永远不会执行。 How can I handle 403 responses? 如何处理403回应? Thanks. 谢谢。
It sounds like you need to handle errors. 听起来您需要处理错误。
$q.all([...])
.then(
function (results) {
// Handle success
}, function (err) {
// Handle errors
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.