Created
July 25, 2017 13:28
-
-
Save danielcrisp/3c966a81a6059f1f19d1421ef0d07f0b to your computer and use it in GitHub Desktop.
AppModule - Async HTTP Interceptors with Angular 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { CommonModule } from '@angular/common'; | |
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; | |
import { AppComponent } from '/app.component'; | |
import { AuthService } from './auth.service'; | |
import { TokenInterceptor } from './token.interceptor'; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
BrowserModule, | |
CommonModule, | |
HttpClientModule | |
], | |
providers: [ | |
AuthService, | |
// register TokenInterceptor as HttpInterceptor | |
{ | |
provide: HTTP_INTERCEPTORS, | |
useClass: TokenInterceptor, | |
multi: true | |
} | |
] | |
}) | |
export class AppModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment