我发送HTTP:
res.status(404).send({message: 'O Captain! My Captain!'});
我在Angular服务中拦截HTTP:
appServices.factory('ErrorInterceptor', ['$q', '$injector', function($q, $injector) {
var ErrorInterceptor = {
responseError: function(response) {
if (response.status == 404){
console.log("[ErrorInterceptor] :" + response.status)
console.log("[ErrorInterceptor] :" + response.message)
}
return $q.reject(response);
}
};
return ErrorInterceptor;
}]);
仅清除状态404
,而不是我的JSON message
成员的值。
答案 0 :(得分:1)
console.log("[ErrorInterceptor] data.error:" + response.data.message)
O Captain! My Captain!