角度インターセプターを使用していて、メッセージから500エラー(内部サーバーエラー)を取得したいとします。角度インターセプター - 500エラーからメッセージを取得
問題は、私はインターセプタ内部rejection.dataでresponseError(下のスクリーンショット)で全体の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を持っているので。私は編集をしました。 –