First time local storage value getting null

First time login when i try get local storage value on that time local storage value getting null but send time login and try to get local storage value its working file working fine

I’m set the value into the local storage like this

 'loggedIn', this.loggedIn);
 'userid', this.userid);
 'license', this.license);
 'userType', this.userType);

And get like this

ionViewDidLoad() {
'license').then(lic => {
          alert(this.license =lic)
          });'username').then(user => {
          alert(this.gaurdname =user);
   'userid').then(id => {
             alert(this.user_id =id)

Please any one help me out

I am also facing this issue since last night, before its working properly.
Give some suggestion if any one have resolved this issue.


You can try like this


	   let self = this;
   setInterval(function () {
  }, 300);	

 getData(){'username').then(val => {
          this.username =val;

If u need setTimeout to resolve async nature of storage then u are missing a fundamental point

U need to chain the storage-set promises (or use Promise.all) and after completion set a flag to say all is stored. And use that in thr storage get sonewhere else to see if there is data stored before u get it.