Skip to content

Instantly share code, notes, and snippets.

@nicowernli
Created March 28, 2019 11:36
Show Gist options
  • Save nicowernli/93546b8060fc11abad038eeae3018732 to your computer and use it in GitHub Desktop.
Save nicowernli/93546b8060fc11abad038eeae3018732 to your computer and use it in GitHub Desktop.
Adds http interceptros to a module
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