0

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

JavaHead
  • 635
  • 1
  • 6
  • 21
  • This depends on the case. What is `condition` and where did it come from? – Estus Flask Jul 11 '17 at 16:13
  • Does it matter? The question is asking how to perform passThrough() ( if at all possible) from within respond . Say I want to log every request that matches the pattern , but not necessarily respond to it. – JavaHead Jul 11 '17 at 17:29
  • 1
    As you can see, it's not possible. The workaround may depend on the particular case. If all you need is just to log all requests, that's one thing. If there is something else like passthrough, it's different. – Estus Flask Jul 11 '17 at 17:43
  • so this regex is a catch all regex which is a passThrough and I was trying to log the requests in it. What would be the workaround for that? – JavaHead Jul 11 '17 at 19:26
  • 1
    To decorate $httpBackend function and/or its methods, similarly to that https://stackoverflow.com/a/43329519/3731501 . – Estus Flask Jul 11 '17 at 19:34

1 Answers1

0

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

JavaHead
  • 635
  • 1
  • 6
  • 21