rosa
rosa

Reputation: 69

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:[]
      }
    })
       
    ],

Upvotes: 6

Views: 4127

Answers (1)

Barremian
Barremian

Reputation: 31115

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:[]
  }
})

Upvotes: 17

Related Questions