I am using ionic native storage to store some data. When i store and retrieve the data using setItem()
and getItem()
it works perfectly. But when i assign a value retrieved by getItem()
in then
block. it does not work outside the block.
showDetails(name: string) {
this.stg.getItem(name).then(data => {
console.log(data);
this.pathName = data.name;
this.type = data.type;
this.positions = JSON.parse(data.positions);
console.log(this.positions);
});
console.log(this.pathName + " " + this.type);
}
When i print the data in the console i got the result and also i got the result when i print a single value inside then
block but the last console.log
shows to me undefined undefined.