Reputation: 11188
I thought to be smart creating a little snippet code that can both fetch and set some data to the local storage with Ionic and Storage. My helper function looks like:
async local(key, value?:any) {
if(value === undefined) {
return await this.storage.get(key);
}
return this.storage.set(key, value);
}
But when I call it from another typescript file like let var = this.helperProvider.local('myTestVar');
I get a 'magic' object as a response:
t {__zone_symbol__state: null, __zone_symbol__value: Array(0)}
__zone_symbol__state
:
true
__zone_symbol__value
:
null
__proto__
:
Object
Is the above possible so my local()
method just returns the value in the local storage?
Upvotes: 0
Views: 4290
Reputation: 249656
The magic object is also a promise you need to await
. Try calling it in another async
function:
(async function() {
let val = await this.helperProvider.local('myTestVar');
console.log(val);
})()
Or use then
this.helperProvider.local('myTestVar').then(val => console.log(val));
Upvotes: 1