I am a little bit confused with Promises. I have the following provider in Ionic + Angular:
@Injectable()
export class StorageProvider {
constructor( public storage:Storage ) {}
save(keyname: string, data: any): Promise<any> {
return this.storage.set(keyname, data);
}
retrieve(keyname: string): Promise<any> {
return this.storage.get(keyname);
}
clear(): Promise<void> {
return this.storage.clear();
}
delete(keyname): Promise<any> {
return this.storage.remove(keyname);
}
isLogged() {
return this.retrieve('user').then( value => { value ? true : false });
}
}
And in one of my components:
console.log(this.storage.isLogged());
The problem is that it returns the promise object and not true or false
If I change my component to:
this.storage.isLogged().then(function(data) { console.log(data)});
Then I get an output of undefined