Open will093 opened 7 years ago
What is the order of imports of HttpModule and HttpInterceptorModulev in your module?
Because if you have HttpModule after HttpInterceptorModule it will override proxied Http service with original one.
@gund The problem still occurs if I import HttpModule first. I was wondering if something like that was occurring, but then I would think InterceptableHttp should still work, which it doesn't.
Yeah you are right, InterceptableHttp
should have been worked any way...
It's weird why requests are not intercepted, can you please make a plunkr with this issue reproduced?
I have the same setup as you, and I was using HttpInterceptorModule.noOverrideHttp()
and I didn't get any logs, I switched to normal module HttpInterceptorModule
and now I can see all requests. (Ionic 3 app).
I have identified the cause of the issue. Another plugin I am using in my project seems to provide its own HTTP implementation via a factory:
https://github.com/aitboudad/ng-loading-bar
As each plugin provides its own implementation of HTTP I think the 2 plugins are incompatible.
Yeah, only the last Http provided will be used. But you should be able to still use InterceptableHttp to make interceptable requests.
I really need to be able to intercept ALL Http requests. Everything throughout my entire app lifecycle, including all DI.
This is a really interesting case when you really want to compose your DI providers but not completely override them.
So far I don't know any solution of how to achieve this but it definitely makes sense in such scenarios.
Maybe we should open an issue in official Angular repo and discuss this problem/feature...
What do you guys think?
I have imported HttpModule and HttpInterceptorModule, and created an interceptor service:
initialise() is then called in the top level AppComponent.
When I debug in Chrome/IE/Firefox I can see http.get is called - but the interceptors never run, and there are no errors. I have tried injecting InterceptableHttp instead of Http, and the interceptors still don't run.
I am using Angular 4, specifically, the versions I am using are: