简体   繁体   English

AngularJs 1.5 $ http后端条件passThrough()

[英]AngularJs 1.5 $httpBackend conditional passThrough()

I want to intercept every call and invoke passtTrough() on all of them , logging the details. 我想拦截每个调用并在所有调用上调用passtTrough(),记录详细信息。

something like : 就像是 :

 $httpBackend.whenGET(/\/*/).respond(function(method, url, data, headers) {
  if(!condition){
      //call passThrough()
  }else{
      //return my mocked object
      return [200, MyTest, {/*headers*/}];
   }    
}

But the API for $httpBackend.whenGET only lets you either call passThrough() or respond() 但是$ httpBackend.whenGET的API仅允许您调用passThrough()或response()

What Estus said in the comments worked. Estus在评论中说的有效。

decorate $httpBackend function and/or its methods, similarly to that stackoverflow.com/a/43329519/3731501 . 装饰$ httpBackend函数和/或其方法,类似于stackoverflow.com/a/43329519/3731501。 – estus Jul 11 at 19:34 – estus 7月11日19:34

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM