Angular 4+ Http Header Interceptor
npm install a4-http-header-interceptor
- Add
HttpModule
to imports of theapp.module.ts
.
...
import { HttpHeaderModule } from 'a4-http-header-interceptor';
...
@NgModule({
declarations: [
AppComponent
],
imports: [
...,
HttpHeaderModule,
...
],
...
})
constructor(private httpHeaderService: HttpHeaderService) { }
this.httpHeaderService.setHeader('key','value');