Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type '' is not assignable to type 'JwtConfig'

I need to put those line into my code. but this error keeps appearing and I'm stuck with this, being not able to find the solution. Please help me.

Type '{ tokenGetter: () => string; whitelistedDomains: string[]; blacklistedRoutes: undefined[]; }' is not assignable to type 'JwtConfig'. Object literal may only specify known properties, and 'whitelistedDomains' does not exist in type 'JwtConfig'.ts(2322) angular-jwt.module.d.ts(14, 5): The expected type comes from property 'config' which is declared here on type 'JwtModuleOptions'

underlined error occurs at whitelistedDomains

app.module.ts

    imports: [
    BrowserModule,
    NgbModule,
    .
    .
    AppRoutingModule,
    JwtModule.forRoot({
      config:{
        tokenGetter:() => {
          return localStorage.getItem('access_token');

        },
        whitelistedDomains: ['localhost:8080'],
        blacklistedRoutes:[]
      }
    })
       
    ],
like image 464
rosa Avatar asked Jul 20 '20 12:07

rosa


1 Answers

If you look at the JwtConfig interface, the whitelistedDomains and blacklistedRoutes properties are not to be found. Probably you were looking for allowedDomains and disallowedRoutes properties. Try the following

JwtModule.forRoot({
  config:{
    tokenGetter:() => {
      return localStorage.getItem('access_token');
    },
    allowedDomains: ['localhost:8080'],
    disallowedRoutes:[]
  }
})
like image 168
ruth Avatar answered Nov 02 '22 10:11

ruth