await works with promise chain
In JavaScript, await
can works with promise chain, it will get the resolved value of the last promise in the chain. For example:
1 | getData = () => |
In above code, getData()
returns a promise chain, the resolved value of the last promise in the chain is 3
, so the output of the code is 3
.
You can even append more promise chain when calling getData()
1 | async function test() { |