Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试将app.module.ts中的存储与angular jwt一起使用时出现非法构造函数错误_Angular_Ionic Framework - Fatal编程技术网

尝试将app.module.ts中的存储与angular jwt一起使用时出现非法构造函数错误

尝试将app.module.ts中的存储与angular jwt一起使用时出现非法构造函数错误,angular,ionic-framework,Angular,Ionic Framework,我刚刚升级了我的Ionic应用程序(3.9.2和Angular 5)。我收到一个“非法”构造函数错误,因为我正在尝试将存储与in-app.module一起使用 还有别的办法吗?我需要确保tokenGetter检索令牌,以便它与每个HTTP请求一起发送 app.module.ts export function jwtOptionsFactory(storage) { return { tokenGetter: () => { return storage.get('

我刚刚升级了我的Ionic应用程序(3.9.2和Angular 5)。我收到一个“非法”构造函数错误,因为我正在尝试将存储与in-app.module一起使用

还有别的办法吗?我需要确保
tokenGetter
检索令牌,以便它与每个HTTP请求一起发送

app.module.ts

export function jwtOptionsFactory(storage) {
  return {
    tokenGetter: () => {
      return storage.get('token');
    },
    whitelistedDomains: ['localhost:8080']
  }
}

  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp, {
    }),
    IonicStorageModule.forRoot(),
    JwtModule.forRoot({
      jwtOptionsProvider: {
        provide: JWT_OPTIONS,
        useFactory: jwtOptionsFactory,
        deps: [Storage] // Storage is a dependancy 
      }
    })
  ],

  providers: [
  .........
  Storage // I need to use Storage so I have to add it as a provider
]