IOnic Storage forEach returns nor all entries

Discussão em 'Angular' iniciado por KTSB, Setembro 2, 2025.

  1. KTSB

    KTSB Guest

    I'm using the ionic storage. In the storage I have 41 entries. Now I would like to read them all into an array. Furthermore, I'd like to filter some out. My code is the following:

    async getEntries() {
    this.trackingEntries = [];
    let promise = new
    Promise((resolve, reject) => {
    this.storage.forEach((value, key, index) => {
    if (key != "Options0" && key != "Options1" && key != "Options2" && key !=
    "Options3" && key != "welcome" && key != "LockedOptions") {
    this.trackingEntries.push(value);
    console.log(index, value)
    }
    }).then(() => {
    console.log(this.trackingEntries) resolve(this.trackingEntries.length);
    });
    });
    return promise;
    }


    My problem is, that the function returns different values. Sometimes 33, sometimes 38 and so on. Can somebody help me to fix this?

    Continue reading...

Compartilhe esta Página