ngx-restangular icon indicating copy to clipboard operation
ngx-restangular copied to clipboard

Integrate HTTP_INTERCEPTORS of Angular as FullRequestInterceptors

Open patrickbussmann opened this issue 6 years ago • 0 comments

If you have HTTP Interceptors from Angular, https://angular.io/api/common/http/HttpInterceptor, then this will be ignored from this ngx-restangular. So it would be nice if someone could integrate this.

src/app/app.module.ts
export function RestangularConfigFactory(RestangularProvider) {
  RestangularProvider.setBaseUrl(environment.url);
  RestangularProvider.addFullRequestInterceptor(AuthInterceptor); // <- Not working!
}

@NgModule({
  imports: [
    RestangularModule.forRoot(RestangularConfigFactory),
    HttpClientModule,
  ],
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
    { provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

Thanks in Advance!

patrickbussmann avatar Nov 23 '19 23:11 patrickbussmann