0

Is it possible to access / modify $http interceptors after the config phase? I'm debugging an app that only breaks in production due to being deployed on a different server, so unfortunately I can't change the interceptor code locally and figure out what's going on.

If it's not possible to access / modify the interceptors, perhaps it'd be possible to replace $http. Here's an example of replacing a hypothetical service:

var inj = angular.element('body').injector(),
    oldGet = inj.get,
    mockService = { secret: 'shhh' };

inj.get = function(str) {
  if (str === 'some-service') {
    return mockService;
  } else {
    return oldGet.apply(inj, arguments);
  }
};

However, I'm not sure how I'd go about creating a new $http service (into which I could pass in the modified interceptors). I can't grab the $httpProvider, either.

Perhaps bootstrapping a new ng-app on a separate part of the page would work? Then I could grab the $http service and replace it, like above.

Other ideas:

Thank you!

Community
  • 1
  • 1
Robert Balicki
  • 1,583
  • 2
  • 16
  • 24
  • Maybe you can add a new dummy interceptor to the interceptor pipeline just for your tracking purpose for now and later remove. This should be a pass through interceptor. – Chandermani Feb 09 '15 at 03:16
  • How would I do this after the config phase? – Robert Balicki Feb 09 '15 at 03:21
  • Yes you cannot do it at config stage, but what is the problem with config stage. Remember you can even write a dummy interceptor in a separate module and use the module's config stage to register the interceptor. – Chandermani Feb 09 '15 at 03:28
  • I was thinking that I'd have to use grease monkey to get that code in fast enough, which is fine (although I haven't tried, so maybe grease monkey will not work for that purpose), but I was wondering if there was another way to do it afterward. – Robert Balicki Feb 09 '15 at 03:31

0 Answers0