Storage value showing undefined

Storage value showing undefined
this way to set value into the local storage'username', this.user_name);
'user_id', this.user_id);

Get this way

 constructor(){'username').then((val) => { =val;

where i’m wrong?
please help me anyone


1 Like

you must use “val” like an object:'username').then((val) => { =val.username;
  });'user_id').then((val) => { =val.user_id;

its still showing same error

please paste here this error

When i try to print the from of showing undefined

TypeError : showing val is null

I guess you run the application in a browser. Storage is native functionality so it works only on the device. All native plugin works only on the device.

I’m following this tutorial

Nope. can and will work in browser.

You need to test for null value, meaning the value is not stored. If that is not what you expect, then there is something else going on. Including the storage being cleared after you close the browser and/or reload the app. Then you need to set the storage engine according to the docs, where still data can be cleared due to the nature of the browser

1 Like

you right

I implemented in my application ‘storage’ and all work fine. In browser developers tools check what value is ‘this.user_name’. Maybe you set a value of ‘null’