I store a value on the service provider and then I get it from a component by using AppPreferences plugin.
the problem is async operation.
fetchKeysAppPreferences(){
this.appPreferences.fetch("key1").then(
(res) => {
this.key.push(JSON.parse(res));
console.log(this.key); //is definded
return this.key;
}
);
console.log(this.key); // undefined
}
I called the fetchKeysAppPreferences() from the home component. I get undefinded value because the async operation. How can I resolve this problem?