HttpInterceptor issues

Hi there,

Not sure where to put this so here it is.

I’m trying to use HttpInterceptor to add an auth token to every request and handle errors generically. However i ran into some known issues. For example a cyclic dependency. This is fixable by injecting the service which calls HttpClient manually.

This however triggers a overflow error of some sort. This can be fixed by placing the http call in a timeout (without miliseconds) so it performs after the init of the service or something like that. However my http call returns a Observable and whenever i put it in a timeout it no longer returns anything (return type of the function becomes void)

I have no clue to why this happens. If anyone has any ideas it would be appreciated

With best regards,

Can you please post something minimally reproducible for the cyclic dependency? I’d like to try to resolve that cleanly first.

Upgrading to angular 5.2.11 actually fixes the cyclic dependency. It allows for the HttpClient to be imported into the HttpInterceptor . (or in my case via a service in the http interceptor)

This in turn also solves the needed timeout which is no longer needed.

I still don’t have it working in my project however. Not really sure why, there are no errors i just dont see a network call happening. This is probably related the me being new to Observables and still in think in promises

It could also be related to us lazy loading our app. I’ve check out a fresh project and implemented the http interceptor which worked as expected