I have 2 function that return promises, P1
and P2
. First I want to wait until P1()
is fulfilled, then I want to execute P2
and when P2()
is fulfilled I want to do something with the value P1()
resolved to. It is easy to do using async/await
like this:
const result = await P1()
await P2()
doSomething(result)
but I cant use async/await
. Using promises I can do it like this:
P1().then((result) => P2().then(() => result)).then((result) => doSomething(result))
but is there any prettier way to do it (without nested then
s)?