小编Gov*_*vil的帖子

AngularJs:从Interceptor中排除一些请求

下面是我的拦截器,它处理全局错误.但我想绕过一些http请求.有什么建议 ?

 var interceptor = ['$rootScope', '$q',function (scope, $q) {
        function success(response) {
            return response;
        }
        function error(response) {
            var status = response.status;
            if (status == 401) {
                window.location = "./index.html#/404";
                return;
            }
            if (status == 0) {
                window.location = "./index.html#/nointernet";
            }
            return $q.reject(response);
        }
        return function (promise) {
            return promise.then(success, error);
        }
    }];
    $httpProvider.responseInterceptors.push(interceptor);
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

13
推荐指数
1
解决办法
7538
查看次数

标签 统计

angularjs ×1

javascript ×1