Angular 4 and global interceptor

Viewed 269

let assume I have multi module angular project. something like https://github.com/start-angular/SB-Admin-BS4-Angular-4

and I have http interceptor. I can successfully connect it to a module (via providers property in @NgModule section of a module).

However, I am not able make it working globally for all modules. I thought that if I add it to app.module.ts (via providers property) it should intercept http request of all other modules. But it does not work like that.

Now in order to intercept requests of a module I need explicitly add this interceptor for each module. It is VERY inconvenient.

Is there a way to configure an interceptor and make it intercept ALL requests of the application?

0 Answers
Related