각도 인터셉터를 사용 중이고 메시지에서 500 개의 오류 (내부 서버 오류)를 가져 오려고합니다.각도 인터셉터 - 500 오류에서 메시지 가져 오기
문제는 내가 요격 내부 responseError에 (아래 스크린 샷)을 rejection.data에서 전체 HTML을 얻고 있다는 것이다.
나는 구성해야한다고 읽었습니다. web.config하지만 여전히 전체 HTML을 얻고 있습니다. 나는 그저 메시지를 듣고 싶다.
그렇게 할 수 있습니까?
각도 인터셉터 :
app.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push(function ($q, $rootScope) {
return {
request: function (config) {
//the same config/modified config/a new config needs to be returned.
return config;
},
requestError: function (rejection) {
//Initializing error list
if ($rootScope.errorList == undefined) {
$rootScope.errorList = [];
}
$rootScope.errorList.push(rejection.data);
//It has to return the rejection, simple reject call doesn't work
return $q.reject(rejection);
},
response: function (response) {
//the same response/modified/or a new one need to be returned.
return response;
},
responseError: function (rejection) {
//Initializing the error list
if ($rootScope.errorList == undefined) {
$rootScope.errorList = [];
}
//Adding to error list
$rootScope.errorList.push(rejection.data);
//It has to return the rejection, simple reject call doesn't work
return $q.reject(rejection);
}
};
});
}]);
의 Web.config 편집
<system.webServer>
<httpErrors existingResponse="PassThrough" errorMode="Detailed"></httpErrors>
</system.webServer>
: 나는 예외 스냅 샷에서 메시지를 얻으려면
당신은 data.message 점점거야? – Disha
아무 것도. 왜냐하면 데이터에서 나는 첫 번째 이미지 에서처럼 전체 HTML을 가지고 있기 때문입니다. 나는 편집을했다. –