我的问题是关于$resource
拦截器(responseError)。我想强调一下,我基于的 angularjs 是V1.3.6
.
问题:
app.factory('authInterceptor',['$q', '$location', '$log', function($q, $location, $log){
$log.debug('this is a regular factory with injection');
return {
responseError: function(response){
console.log(response)
// problem is that I cant check 401 by response.status,
// because the response here is AN ERROR OBJECT like `SyntaxError: ...`. Anyway to get the status?
return $q.reject(response);
}
}
}])
当我收到 401 响应时,responseError
的参数是 AN ERROR OBJECT ,因为来自服务器的响应是带有 statusSyntaxError: Unexpected token U
的纯文本。Unathorized
401
但我想得到 ,如果是response.status
,就做点什么401
。
任何帮助将不胜感激。