Angular2-jwt: @auth0/angular-jwt tokenGetter can't resolve in module

Created on 19 Jul 2017  路  2Comments  路  Source: auth0/angular2-jwt

JwtModule.forRoot({
      config: {
        tokenGetter: () => {
          return localStorage.getItem('access_token');
        },
        whitelistedDomains: ['localhost:3001']
      }
    })

i have been add this line in app.module.ts but on first run (ng serve) i am getting error.

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 30:22 in the original .ts file), resolving symbol AppModule in ..../src/app/app.module.ts

And error line is tokenGetter.

Most helpful comment

Looking at the error message I suggest you to try the following solution.

  export function getToken() {
   return localStorage.getItem('access_token');
  }

  JwtModule.forRoot({
      config: {
        tokenGetter: getToken,
        whitelistedDomains: ['localhost:3001']
      }
    })

All 2 comments

Looking at the error message I suggest you to try the following solution.

  export function getToken() {
   return localStorage.getItem('access_token');
  }

  JwtModule.forRoot({
      config: {
        tokenGetter: getToken,
        whitelistedDomains: ['localhost:3001']
      }
    })

@lekhnath damn. Thank you so much. Sometimes missing. Thank you again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hang321 picture hang321  路  4Comments

JaxonWright picture JaxonWright  路  4Comments

sfabriece picture sfabriece  路  4Comments

huineng picture huineng  路  4Comments

leosvelperez picture leosvelperez  路  5Comments