0
500错误不会我有这个拦截器设置读取XML我收到我的所有请求:现在,当服务器返回500错误 https://gist.github.com/SantechDev/539a70208d23d8918ce0AngularJS - 服务器通过拦截
,它似乎并不像响应通过拦截器。我试过记录反应,但没有出现
有人会知道为什么吗?
500错误不会我有这个拦截器设置读取XML我收到我的所有请求:现在,当服务器返回500错误 https://gist.github.com/SantechDev/539a70208d23d8918ce0AngularJS - 服务器通过拦截
,它似乎并不像响应通过拦截器。我试过记录反应,但没有出现
有人会知道为什么吗?
我不知道你是如何工作,但我写的那些看起来完全不同..
var interceptor = ['$rootScope', '$q', "Base64", function (scope, $q, Base64) {
function success(response) {
return response;
}
function error(response) {
var status = response.status;
if (status == 401) {
window.location = "/account/login?redirectUrl=" + Base64.encode(document.URL);
return;
}
// otherwise
return $q.reject(response);
}
return function (promise) {
return promise.then(success, error);
}
}];
$httpProvider.responseInterceptors.push(interceptor);
你可以检查出full code here。
对于迟到的回复感到抱歉。其实我忘了设置transformError。所以你的回答是对的 –