Typescript returning boolean after promise resolved

Viewed 68458

I'm trying to return a boolean after a promise resolves but typescript gives an error saying

A 'get' accessor must return a value.

my code looks like.

get tokenValid(): boolean {
    // Check if current time is past access token's expiration
    this.storage.get('expires_at').then((expiresAt) => {
      return Date.now() < expiresAt;
    }).catch((err) => { return false });
}

This code is for Ionic 3 Application and the storage is Ionic Storage instance.

2 Answers
Related