@angular/common/http#HTTP_INTERCEPTORS TypeScript Examples

The following examples show how to use @angular/common/http#HTTP_INTERCEPTORS. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: util-i18n.module.ts    From geonetwork-ui with GNU General Public License v2.0 7 votes vote down vote up
@NgModule({
  imports: [
    HttpClientModule,
    ApiModule,
    TranslateModule.forChild(),
    CommonModule,
  ],
  exports: [],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: I18nInterceptor, multi: true },
  ],
})
export class UtilI18nModule {
  constructor(translate: TranslateService) {
    translate.setDefaultLang(DEFAULT_LANG)
    translate.use(DEFAULT_LANG)
  }
}
Example #2
Source File: shared.module.ts    From assetMG with Apache License 2.0 6 votes vote down vote up
@NgModule({
  declarations: [
    ProgressBtnComponent,
    LoaderComponent,
    CredentialsComponent,
    RefreshCodeComponent,
    UploadComponent,
    ClientIDPipe,
    ErrorMsgPipe,
    YtConifgComponent,
  ],
  imports: [CommonModule, FormsModule, ReactiveFormsModule, MaterialModule],
  exports: [
    ProgressBtnComponent,
    LoaderComponent,
    CredentialsComponent,
    RefreshCodeComponent,
    MaterialModule,
    FormsModule,
    ReactiveFormsModule,
    UploadComponent,
    ErrorMsgPipe,
    YtConifgComponent,
  ],
  providers: [
    LoaderService,
    ClientIDPipe,
    ErrorMsgPipe,
    { provide: HTTP_INTERCEPTORS, useClass: LoaderInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: HttpErrorInterceptor, multi: true },
  ],
})
export class SharedModule {}
Example #3
Source File: app.module.ts    From careydevelopmentcrm with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
    MenuListItemComponent,
    FeaturesComponent,
    ConfirmationDialogComponent
  ],
  imports: [
    BrowserModule,
    FlexLayoutModule,
    HttpClientModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatToolbarModule,
    MatSidenavModule,
    MatListModule,
    MatIconModule,
    MatDialogModule,
    MatButtonModule,
    MatNativeDateModule,
    BreadcrumbModule,
    UserModule.forRoot({ baseUrl: environment.baseUserServiceUrl }),
    AuthModule.forRoot({ baseUrl: environment.baseUserServiceUrl }),
    GeoModule.forRoot({ baseUrl: environment.baseGeoServiceUrl }),
    ValidationModule.forRoot({ fieldSummaries : allFieldSummaries })
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: HttpErrorInterceptor, multi: true }
  ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #4
Source File: app.module.ts    From angular-10-basic-authentication-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        LoginComponent
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: BasicAuthInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #5
Source File: app.module.ts    From angular-10-facebook-login-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        EditAccountComponent,
        LoginComponent
    ],
    providers: [
        { provide: APP_INITIALIZER, useFactory: appInitializer, multi: true, deps: [AccountService] },
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #6
Source File: app.module.ts    From angular-10-jwt-authentication-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        LoginComponent
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #7
Source File: app.module.ts    From angular-10-jwt-refresh-tokens with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        LoginComponent
    ],
    providers: [
        { provide: APP_INITIALIZER, useFactory: appInitializer, multi: true, deps: [AuthenticationService] },
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #8
Source File: app.module.ts    From angular-10-registration-login-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        AlertComponent,
        HomeComponent
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #9
Source File: app.module.ts    From angular-10-role-based-authorization-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        HomeComponent,
        AdminComponent,
        LoginComponent
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})

export class AppModule { }
Example #10
Source File: app.module.ts    From angular-10-signup-verification-boilerplate with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        AlertComponent,
        HomeComponent
    ],
    providers: [
        { provide: APP_INITIALIZER, useFactory: appInitializer, multi: true, deps: [AccountService] },
        { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },

        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #11
Source File: app.module.ts    From mysql_node_angular with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [AppComponent, HeaderComponent, FooterComponent],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MaterialModule,
    SidebarModule,
    HttpClientModule,
    ReactiveFormsModule,
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: AdminInterceptor, multi: true },
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
Example #12
Source File: app.module.ts    From angular-11-crud-example with MIT License 6 votes vote down vote up
@NgModule({
    imports: [
        BrowserModule,
        ReactiveFormsModule,
        HttpClientModule,
        AppRoutingModule
    ],
    declarations: [
        AppComponent,
        AlertComponent,
        HomeComponent
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
        
        // provider used to create fake backend
        fakeBackendProvider
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Example #13
Source File: app.module.ts    From IntelOwl-ng with GNU Affero General Public License v3.0 6 votes vote down vote up
@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    HttpClientModule,
    AppRoutingModule,
    NbEvaIconsModule,
    NbSidebarModule.forRoot(),
    NbMenuModule.forRoot(),
    NbToastrModule.forRoot(),
    CoreModule.forRoot(),
    ThemeModule.forRoot(),
  ],
  bootstrap: [AppComponent],
  providers: [
    AuthGuard,
    ToastService,
    DexieService,
    IndexedDbService,
    { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true },
    { provide: APP_BASE_HREF, useValue: '/' },
  ],
})
export class AppModule {}
Example #14
Source File: app.server.module.ts    From nestjs-angular-starter with MIT License 6 votes vote down vote up
@NgModule({
  imports: [AppModule, ServerModule, NoopAnimationsModule, ServerTransferStateModule],
  providers: [
    // Add server-only providers here.
    {
      provide: HTTP_INTERCEPTORS,
      useClass: UniversalRelativeInterceptor,
      multi: true,
    },
  ],
  bootstrap: [AppComponent],
})
export class AppServerModule {}
Example #15
Source File: app.module.ts    From StraxUI with MIT License 6 votes vote down vote up
@NgModule({
  imports: [
    BrowserModule,
    HttpClientModule,
    BrowserAnimationsModule,
    SharedModule,
    SetupModule,
    WalletModule,
    AppRoutingModule,
    NgxPaginationModule
  ],
  declarations: [
    AppComponent,
    LoginComponent
  ],
  providers: [ { provide: HTTP_INTERCEPTORS, useClass: ApiInterceptor, multi: true}, AuthenticationService, AuthenticationGuard ],
  bootstrap: [ AppComponent ]
})

export class AppModule { }
Example #16
Source File: api-rest-interceptor.module.ts    From taiga-front-next with GNU Affero General Public License v3.0 6 votes vote down vote up
@NgModule({
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: ApiRestInterceptorService, multi: true },
  ],
  declarations: [],
  imports: [
    LocalStorageModule,
  ],
})
export class ApiRestInterceptorModule { }
Example #17
Source File: core.module.ts    From nodejs-angular-typescript-boilerplate with Apache License 2.0 6 votes vote down vote up
interceptors = [
  {
    provide: HTTP_INTERCEPTORS,
    useClass: ApiPrefixInterceptor,
    multi: true,
  },
  {
    provide: HTTP_INTERCEPTORS,
    useClass: LoaderInterceptor,
    multi: true,
  },
  {
    provide: HTTP_INTERCEPTORS,
    useClass: TokenInterceptor,
    multi: true,
  },
  {
    provide: HTTP_INTERCEPTORS,
    useClass: ErrorHandlerInterceptor,
    multi: true,
  },
]
Example #18
Source File: app.module.ts    From matx-angular with MIT License 6 votes vote down vote up
@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    SharedModule,
    HttpClientModule,
    PerfectScrollbarModule,

    InMemoryWebApiModule.forRoot(InMemoryDataService, { passThruUnknownUrl: true}),
    RouterModule.forRoot(rootRouterConfig, { useHash: false })
  ],
  declarations: [AppComponent],
  providers: [
    { provide: ErrorHandler, useClass: ErrorHandlerService },
    { provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig },
    { provide: PERFECT_SCROLLBAR_CONFIG, useValue: DEFAULT_PERFECT_SCROLLBAR_CONFIG },
    
    // REQUIRED IF YOU USE JWT AUTHENTICATION
    {
      provide: HTTP_INTERCEPTORS,
      useClass: TokenInterceptor,
      multi: true,
    },
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Example #19
Source File: app.module.ts    From yii-debug-frontend with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NgModule({
    declarations: [AppComponent],
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        IndexModule,
        ViewModule,
        MatSidenavModule,
        HttpClientModule,
    ],
    providers: [
        { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true },
        ErrorService,
        MatSnackBar,
        Overlay,
    ],
    bootstrap: [AppComponent],
})
export class AppModule {}
Example #20
Source File: app.module.ts    From distributed-compliance-ledger with Apache License 2.0 6 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    AppRoutingModule,
    DashboardModule,
    CoreModule,
    NgbModule
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: BaseUrlInterceptor, multi: true },
    { provide: 'BASE_API_URL', useValue: environment.apiUrl },
    { provide: 'CHAIN_ID', useValue: environment.chainId },
    { provide: NgbDateAdapter, useClass: NgbDateNativeAdapter }
  ],
  bootstrap: [
    AppComponent
  ]
})
export class AppModule {
}
Example #21
Source File: auth.module.ts    From ngx-admin-dotnet-starter with MIT License 6 votes vote down vote up
static forRoot(): ModuleWithProviders<AuthModule> {
    return {
      ngModule: AuthModule,
      providers: [
        { provide: NB_AUTH_TOKEN_INTERCEPTOR_FILTER, useValue: filterInterceptorRequest },
        { provide: HTTP_INTERCEPTORS, useClass: NbAuthJWTInterceptor, multi: true },
        { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
        ...GUARDS],
    };
  }
Example #22
Source File: auth-store.module.ts    From svvs with MIT License 6 votes vote down vote up
static forRoot(options: Partial<IAuthStoreOptions> = {}): ModuleWithProviders<AuthStoreModule> {
    return {
      ngModule: AuthStoreModule,
      providers: [
        {
          provide: HTTP_INTERCEPTORS,
          useClass: AuthInterceptor,
          multi: true
        },
        {
          provide: IAuthFacade,
          useClass: options.facade || BaseAuthFacade
        },
        {
          provide: IAuthStorage,
          useClass: options.storage || BaseAuthStorage
        },
        {
          provide: IAuthApollo,
          useClass: options.apollo || BaseAuthApollo
        }
      ]
    }
  }
Example #23
Source File: app.module.ts    From auth0-angular with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
    ProtectedComponent,
    UnprotectedComponent,
    ChildRouteComponent,
    NestedChildRouteComponent,
    ErrorComponent,
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    ReactiveFormsModule,
    HttpClientModule,

    // This playground has been configured by default to use dynamic configuration.
    // If you wish to specify configuration to `forRoot` directly, uncomment `authConfig`
    // here, and comment out the APP_INITIALIZER config in the providers array below.
    AuthModule.forRoot(/* authConfig */),
  ],
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: configInitializer,
      deps: [HttpBackend, AuthClientConfig],
      multi: true,
    },
    { provide: HTTP_INTERCEPTORS, useClass: AuthHttpInterceptor, multi: true },
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
Example #24
Source File: error-handler.module.ts    From angular-padroes-e-boas-praticas with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [],
  imports: [ CommonModule ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: HttpErrorInterceptor,
      multi: true
    }
  ]
})
export class ErrorHandlerModule {}
Example #25
Source File: auth.module.ts    From budget-angular with GNU General Public License v3.0 6 votes vote down vote up
@NgModule({
  declarations: [
    LoginComponent,
    SignupComponent,
    ConfirmComponent,
    ForRolesDirective,
    PasswordComponent,
    RecoverComponent,
    OAuthComponent,
    OtpComponent,
  ],
  exports: [ForRolesDirective],
  imports: [
    CommonModule,
    RouterModule,
    AuthRoutingModule,
    FormsModule,
    ReactiveFormsModule,
    MatButtonModule,
    MatFormFieldModule,
    MatInputModule,
    MatDialogModule,
  ],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: AuthInterceptor,
      multi: true,
    },
    authStrategyProvider,
  ],
})
export class AuthModule {}
Example #26
Source File: app.module.ts    From NetCoreTutes with MIT License 6 votes vote down vote up
@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    LoginComponent,
    SecretComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireAuthModule,
    HttpClientModule
  ],
  providers: [
    AuthGuardGuard,
    { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Example #27
Source File: app.module.ts    From The-TypeScript-Workshop with MIT License 6 votes vote down vote up
@NgModule({
  imports: [BrowserModule, HttpClientModule],
  declarations: [AppComponent, WelcomeMessageComponent, UsersListComponent],
  providers: [
    UsersService,
    { provide: HTTP_INTERCEPTORS, useClass: ApiHttpInterceptor, multi: true }
  ],
  bootstrap: [AppComponent],
})
export class AppModule { }
Example #28
Source File: index.ts    From blockcore-hub with MIT License 6 votes vote down vote up
httpInterceptorProviders = [
    // { provide: HTTP_INTERCEPTORS, useClass: NoopInterceptor, multi: true },

    // { provide: HTTP_INTERCEPTORS, useClass: EnsureHttpsInterceptor, multi: true },
    // { provide: HTTP_INTERCEPTORS, useClass: TrimNameInterceptor, multi: true },

    // { provide: HTTP_INTERCEPTORS, useClass: NodeInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptor, multi: true },

    // { provide: HTTP_INTERCEPTORS, useClass: UploadInterceptor, multi: true },
    // { provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true },

]
Example #29
Source File: authorization.module.ts    From alura_angular_rxjs_1 with MIT License 6 votes vote down vote up
@NgModule({
  imports: [CommonModule],
  providers: [
    {
      provide: HTTP_INTERCEPTORS,
      useClass: AuthorizationInteceptor,
      multi: true,
    },
  ],
})
export class AuthorizationModule {}