ionic-team / ionic-team/ionic-storage
Method get is not working
- Vorherrschende Sprache
- TypeScript
- Sterne
- 456
- Forks
- 97
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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 {
console.log(key);
const data = await this._storage?.get(key);
console.log(data);
return data;
}
}
```
The console shows:
login
storage.service.ts:31 undefined
Beitragsleitfaden
Rechercherichtung
Start with the StorageService code shown in storage.service.ts, especially init(), set(), and get(), and reproduce the undefined result using the logged key. Trace when storage.create() completes relative to calls to get and set, then confirm that a completed storage operation returns the stored value rather than undefined.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- database
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100