Save Storage Value as variable

Please Share your solution. Cause even i am stuck at the same problem :frowning:

1 Like

Sorry, totally forgot it. The problem is created by ionicยดs async.

So basically, you need to catch it with this function:

  async getValue(){ 
    return await this.storage.get("Value");
  }

and then call it as

 this.getValue().then((result) => {
        this.valuenew = result; 
});

this should do it.

by doing this

this.getValue().then((result) => {
        this.valuenew = result; 
});

the value is assigned only inside the callback function you cannot carry that value out the function.
so my question is how can we assign the value coming from storage.get to a global variable?