storage. get function return null value out side the function. here is my code
username:any;
this.storage.get('user').then((value) => {
this.username = value;
});
console.log(this.username);
output : undefined;
storage. get function return null value out side the function. here is my code
username:any;
this.storage.get('user').then((value) => {
this.username = value;
});
console.log(this.username);
output : undefined;
Why are you using function ? You can simply get the store value with the following code:
this.username = JSON.parse(localStorage.getItem('user'));
if you want to use local storage:
username:any;
this.username = localStorage.getItem('user');
console.log(this.username);