How to inject application configuration and add HTTP interceptor to standalone component

280 views Asked by At

I am doing it as follows but this is not possible as boostrapapplication expects 1 or 2 arguments.

import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { ExampleInterceptor } from '../../../libs/shared/src/interceptors/example.interceptor';

bootstrapApplication(AppComponent, appConfig, {
  providers: [
    { provide: HTTP_INTERCEPTORS, useClass: ExampleInterceptor, multi: true }
  ]
}).catch((err) => console.error(err));
1

There are 1 answers

0
Matthieu Riegler On

You need to add the providers to the appConfig object. It already contains other provider definitions.