0

I have a Card class where I am calling an all() function. I am doing a promise call inside it but I never get the result back. Any idea why?

class Card {
  static all() {
    this.getUsers().then((result) => {
      console.log('result') // doesn't print
      return result
    })
  }
  get getUsers() {
    return new Promise((resolve) => {
      console.log('test')// doesn't print
      chrome.storage.local.get({ user: [] }, function (result) {
        chrome.storage.local.set({ user: [] }, () => { });
        resolve(result.user);
      });
    });
  }
}

let profile = new CardProfile(element).all()
HeelMega
  • 458
  • 8
  • 23
  • 1
    `all` shouldn’t be `static`!? `all` needs to `return this.getUsers()`. – deceze Jun 27 '20 at 20:16
  • If you want to call `this.getUsers()`, then `getUsers` should not be a getter property but a normal method - drop the `get` keyword. – Bergi Jun 27 '20 at 23:50
  • 1
    The code you posted does throw multiple exceptions before the promise even comes into play. – Bergi Jun 27 '20 at 23:51

0 Answers0