Issue
Hi I am developing an ionic-angular pwa and recently I decided to use local storage to store authentication info. I followed the steps according to Ionic Storage
But in the end I get the following error:
AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Cannot read property 'platformId' of undefined
at provideStorage (ionic-storage-angular.js:49)
at _callFactory (core.js:23707)
at _createProviderInstance (core.js:23663)
The only way I could solve the error is to add Storage to the Providers list in app.module.ts; But according to recent release I should not. I would be thankful if you can tell my what is wrong.
My packages versions are:
"@ionic/angular": "^5.5.2",
"@ionic/storage": "^2.3.1",
"@ionic/storage-angular": "^3.0.6",
Solution
I was able to solve this error by adding Storage to the Providers list in app.module.ts. However you need to import the Storage package from @ionic/storage-angular rather than @ionic/storage. I know that the recent release currently says not to do this, but i was unable to run my application with this entry.
Try this in your app.module.ts
import { IonicStorageModule,Storage } from '@ionic/storage-angular';
@NgModule({
imports: [
IonicStorageModule.forRoot()
],
providers: [
Storage
]
})
export class AppModule { }
And this is the only way it worked for me.
Answered By - You Rule Avi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.