-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Description
Hello.
I'm using "@ionic/storage-angular": "^4.0.0" on the project. But, the method get return undefined.
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage-angular';
@Injectable({
providedIn: 'root'
})
export class StorageService {
private _storage: Storage | null = null;
constructor(private storage: Storage) {
this.init();
}
async init() {
// If using, define drivers here: await this.storage.defineDriver(/*...*/);
const storage = await this.storage.create();
this._storage = storage;
}
// Create and expose methods that users of this service can
// call, for example:
public set(key: string, value: any) {
this._storage?.set(key, value);
}
public async get(key: string): Promise<any> {
console.log(key);
const data = await this._storage?.get(key);
console.log(data);
return data;
}
}
The console shows:
login
storage.service.ts:31 undefined
Metadata
Metadata
Assignees
Labels
No labels