import { NgModule , Optional , SkipSelf } from '@angular/core' ; import { HttpClientModule , HTTP_INTERCEPTORS } from '@angular/common/http' ; import { AuthInterceptor } from './interceptors/auth.interceptor' ; @ NgModule ( { imports : [ HttpClientModule ] , declarations : [ ] , providers : [ { provide : HTTP_INTERCEPTORS , useClass : AuthInterceptor , multi : true } ] } ) export class CoreModule { constructor ( @ Optional ( ) @ SkipSelf ( ) parentModule ) { if ( parentModule ) { throw new Error ( 'Core is already loaded. Import it in the AppModule only' ) ; } } }