Created
March 28, 2019 11:36
-
-
Save nicowernli/93546b8060fc11abad038eeae3018732 to your computer and use it in GitHub Desktop.
Adds http interceptros to a module
This file contains hidden or 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 {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http'; | |
import {AppComponent} from './app.component'; | |
import {BaseURLInterceptor} from './services/base-url.interceptor'; | |
import {HttpErrorInterceptor} from './services/http-error.interceptor'; | |
@NgModule({ | |
declarations: [ AppComponent ], | |
imports: [ | |
BrowserModule, | |
HttpClientModule | |
], | |
providers: [ | |
{ provide: HTTP_INTERCEPTORS, useClass: BaseURLInterceptor, multi: true }, | |
{ provide: HTTP_INTERCEPTORS, useClass: HttpErrorInterceptor, multi: true } | |
], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment