Restangular - $ http interceptors

Morning

I have a $ http interceptor:

app.factory('Unauthed', ['$q', 'alertService',function($q,alertService) {
    return {
        response: function (response) {
            if (response.status == 401) 
                alertService.error('Authentication failure.',15000);

            return response || $q.when(response);
        }
    };
}]);

This works fine for all requests that go through $ http, but not through Restangular. Looking through surah, Restangular uses $ http, so I'm not sure what is going on here?

Greetings

+4
source share
1 answer

Maybe execution order matters where you register restangular? It is also possible to order dependencies of angular modules, try declaring restangular as a dependency of submodules, but not in the main application module, so $ http is already decorated when you add restangular.

0
source

Source: https://habr.com/ru/post/1536573/


All Articles