Tuesday, 15 January 2013

angularjs - httpInterceptor response called several times for one response shown in network -


I am trying to use http interceptor in my angle program. Now, I see in the console that a request is removed Given and respond successfully, but if I add a console log in response to httpInterceptor, then the console log is removed multiple times (~ 10 times).

I add the interceptor in the config section of my app like this:

  $ httpProvider.interceptors.push ('httpInterceptor');  

I define it like this:

  .factory ('httpInterceptor', ['$ q', '$ rootscope', function ($ Q, $ RootScope) {var numLoadings = 0; return {response: function} {console.log ('response:', response); return response || $ q.when (response);}};}]) ;  


No comments:

Post a Comment