AngularJS中$ http拦截器的执行顺序是什么?

时间:2016-03-21 17:01:24

标签: angularjs

假设我在angular.js app中注册了几个HTTP拦截器:

nil

他们将以何种顺序执行?

1 个答案:

答案 0 :(得分:9)

似乎执行了拦截器:

  • 注册订单中处理请求
  • 反向注册订单中进行回复

日志:

  $httpProvider.interceptors.push(function() {
    return {
      request: function(config) {
        console.log("interceptor A request");
        return config;
      },
      response: function(res) {
        console.log("interceptor A response");
        return res;
      }
    };
  });
  $httpProvider.interceptors.push(...); // interceptor B with similar code
  $httpProvider.interceptors.push(...); // interceptor C with similar code