Hello,
I am trying implementation JWT with https://github.com/vmanchev/ionic3-seed-jwt but I didn’t able it. Last, I got that error
Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0__angular_core__.OpaqueToken is not a constructor
at Object.<anonymous> (storage.js:230)
at __webpack_require__ (bootstrap 1eb62cb7ba312b8c5f2e:54)
at Object.defineProperty.value (vendor.js:60850)
at __webpack_require__ (bootstrap 1eb62cb7ba312b8c5f2e:54)
at Object.159 (main.js:56)
at __webpack_require__ (bootstrap 1eb62cb7ba312b8c5f2e:54)
at Object.161 (main.js:201)
at __webpack_require__ (bootstrap 1eb62cb7ba312b8c5f2e:54)
at Object.700 (main.js:950)
at __webpack_require__ (bootstrap 1eb62cb7ba312b8c5f2e:54)
Thanks.
EDIT
I imported these packages in app.module.ts
import {AuthHttp, AuthConfig} from 'angular2-jwt';
import {IonicStorageModule} from '@ionic/storage';
import {HttpModule, Http} from '@angular/http';
import { AuthService } from '../providers/auth-service/auth-service';
Then use this constructor in app.module.ts
export function getAuthHttp(http, storage) {
return new AuthHttp(new AuthConfig({
noJwtError: true,
globalHeaders: [{'Accept': 'application/json'}],
tokenGetter: (() => storage.get('id_token')),
}), http);
}
And providers section in app.module.ts
providers: [
{ provide:
...
{ provide: ErrorHandler, useClass: IonicErrorHandler },
{
provide: AuthHttp,
useFactory: getAuthHttp,
deps: [Http, Storage]
},
...
AuthService,
]
EDIT 2
If I try to run it on my phone I get an error like;
[20:10:38] typescript: .../node_modules/@ionic/storage/es2015/storage.d.ts, line: 2
Module
'"/node_modules/@angular/core/core"' has
no exported member 'OpaqueToken'.
L1: import { OpaqueToken } from '@angular/core';
L3: * Storage is an easy way to store key/value pairs and JSON objects.
Error: Failed to transpile program
at new BuildError (..\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28)
at ..\node_modules\@ionic\app-scripts\dist\transpile.js:159:20
at new Promise (<anonymous>)
at transpileWorker (..\node_modules\@ionic\app-scripts\dist\transpile.js:107:12)
at Object.transpile (..\node_modules\@ionic\app-scripts\dist\transpile.js:64:12)
at ..\node_modules\@ionic\app-scripts\dist\build.js:109:82
at <anonymous>