I’m using the library @auth0/angular-jwt as the jwt implementation system for my angular 17 app and i’m facing a little issue.
The part of the module config is this :
importProvidersFrom([
HttpClientModule,
JwtModule.forRoot({
config: {
tokenGetter: () => localStorage.getItem('token')
}
}),
The issue i’m facing is that when the token is no longer present in the local storage OR it does not contain a JWT, my app breaks with this error message ERROR Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with runInInjectionContext
So it looks like this library forces us to always provide a token to the config, but what if the user removes it manually or if i need to logout and remove the token ?
Is there a way to bypass this constraint ?