문제

I've got this interceptor setup to read XML I receive on all my requests: https://gist.github.com/SantechDev/539a70208d23d8918ce0

Now when the server returns a 500 error, it doesn't seem like the response goes through the interceptor. I tried logging response but nothing comes up

Would anyone know why?

도움이 되었습니까?

해결책

I don't know how yours has to work but the ones I wrote look totally different..

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);

you can check out the full code here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top