Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70443

Storage.get returns null on init app

$
0
0

Hi, im using Storage module, my problem is when i try to get stored data on application init.
the first time no data is loaded, when i call a second time the same method ( " this.storeService.getUserData(); ") data is loaded well.

i have called my storage service on constructor of my homepage.ts, like this:

//Ready event is raised well, if i put a toast here it is shown
  this.plt.ready().then((readySource) => {
       this.dataUser= this.storeService.getUserData(); 
    });

in getUserData Method i have the folowing code:

getUserData(){
  this.getStoreduser(); 
  return JSON.parse(this.userData);
}

and in the StoreService class constructor i have:


//I have tried without storage.ready but is the same
this.storage.ready().then((readySource) => {
        this.getStoreduser();
 
      });

and the method getStoredUser:

async  getStoreduser(){
    await this.storage.get(this.KEY_USR).then(res=>{
       this.userData=res;

    },err=>{
      return null;
    });
   }

i dont know what is my problem, can you help me please?

Regards

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70443

Trending Articles