Hi !
I want to use SQL Storage in my Ionic 2 app to store the user token after he is logged in.
When I use the get method I receive an object of type :
ZoneAwarePromise {__zone_symbol__state: null, __zone_symbol__value: Array[0]}
with my token in the zone_symbol value array but I cannot retrieve the token from the array.
Your problem is not about local storage, the problem is of returning token inside then handler.
you cannot return value directly from promise, either you can return promise object or new promise if you want to do any reusable manipulation task.
I followed your solution and it seems that the value is returned properly but I don’t know why it keeps in a never ending loop between the two methods. This is my code. Hope someone can help. Thanks in advance
public authenticated() {
var isAuthenticated = this.isAuthenticated().then(
alfTicket => {
console.log(alfTicket);
return alfTicket;
}
);
return isAuthenticated !== null; }
There is silly mistake of how you are consuming isAuthenticated() promise method. in authenticated() method, you putting statement “isAuthenticated !== null;”, which will compare promise object with !== null (not with promise value, what you are returning). So authenticated must be some promise. Its matter of how you are using authenticated method, you use following approach.