Storage get value

Hi,
it’s OK.

		this.storage.get('buttonBool').then((data)=>{this.flag=data;});
		this.storage.get('buttonBool').then((data)=>{console.log(this.flag);});

But

		this.storage.get('buttonBool').then((data)=>{this.flag=data;});
		console.log(this.flag);

why undefined value?
How do I use it?

	storageGet(){
		Promise.all([
		this.storage.get('name').then((data)=>{this.var=data;}),})]);
		console.log(this.var.toString());
	}


ı’m using above
but same thing

Same problem: The Promises only resolve after console.log already executed. You have to use .then for Promise.all so the console.log only gets executed after all the inner Promises resolved.

Ok.but I use different function this.attribute undefined

	ionViewDidLoad(){
		this.storageGet();;}

Same problem: You execute stuff in this.storageGet async, then execute console.log directly while it is not yet finished. You have to return the promise in storageGet you get from Promise.all and use then() on storageGet.

such is?

ionViewWillEnter(){
    Promise.all([]).then(()=>this.storageGet());
 
}

  storageGet(){
    this.storage.get('name').then((data)=>{this.var=data;});
}

i think it should be

var promise1= this.local.get('id');
var promise2 = this.local.get('name');

Promise.all([promise1, promise2 ]).then((arrayOfResults) => {
console.log(arrayOfResults[0]);
console.log(arrayOfResults[1]);
});

storageGet function console write
but ionViewWillEnter console not write

  ionViewWillEnter(){
    this.storageGet();;}

storageGet(){
    var x0=this.storage.get('name');


  Promise.all([x0]).then((arrayOfResults) => {
    this.var=arrayOfResults[0]; console.log(arrayOfResults[0]);
  });

As I said in the thread that @auspicious linked to earlier, I think your code would be more performant as well as far easier to read, write, and maintain, if you would just combine all of these properties into a single JSON interface instead of storing them all separately.

I am facing exact same issue do you has a solution to this problem

you use method async and get storage value await storage.get

Found Perfect Solution on stackoverflow