AngularJs 1.5 $httpBackend conditional passThrough()

123 Views Asked by At

I want to intercept every call and invoke passtTrough() on all of them , logging the details.

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()

1

There are 1 best solutions below

0
JavaHead On

What Estus said in the comments worked.

decorate $httpBackend function and/or its methods, similarly to that stackoverflow.com/a/43329519/3731501 . – estus Jul 11 at 19:34