Accessing the await-ed value inline (JS)?

you need to await on a promise, not a property of one. JavaScript is going to expect a to be a promise, but its not.

await is an operator statement, not a function.


You need to wrap the await keyword and the promise in parentheses, like that:

const value = (await Promise.resolve({a: 3})).a;

This way you're awaiting the promise and then accessing the a property of the resolved value.

await(Promise.resolve({a: 3})).a doesn't work, because await is not a function, but an operator.