Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top