0

How can I get the value out of Promise?

let id = getUserID(email, args, context)
        .then(id => id);

I'm using then but still Promise not resolved.

unknown_boundaries
  • 1,482
  • 3
  • 25
  • 47
  • 3
    You can only get the value in the `then` callback. Promises don't make your code synchronous. – Felix Kling Jan 31 '19 at 18:24
  • I didn't get it @FelixKling - could you please share any link. – unknown_boundaries Jan 31 '19 at 18:33
  • See the first duplicate. But basically: `.then(id => )`. I suggest to put all the code that needs to access `id` into a function that accepts `id` as an argument and do `.then(thatFunction)`. – Felix Kling Jan 31 '19 at 18:50
  • If you are familiar with using `async`/`await`, you can do this in an `async` function: `let id = await getUserId(email, args, context);` – Terry Jan 31 '19 at 19:20

0 Answers0