假设我在 angular.js 应用程序中注册了几个 HTTP 拦截器:
$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
它们将按什么顺序执行?
最佳答案
似乎执行了拦截器:
日志:
interceptor A request
interceptor B request
interceptor C request
(request happens here)
interceptor C response
interceptor B response
interceptor A response