How to get the LocalStorage value out of promise scope ionic 4

i prefer the async/await syntax for promises, it feels easier to read
the method needs to return some value if you are assigning it to a variable

async getStorage(): Proimise<any> {
    try {
        const result =  await this.storage.get('user_id');
        console.log(result);
        return result;
    }
    catch(e) { console.log(e) }
}

let value = this.getStorage();

alternatively, without async:

getStorage() {
    return this.storage.get('user_id').then((result) => {
        console.log(result);
        return result;
    });
}

let value = this.getStorage();

do either of these work?

1 Like