69
rated 0 times
[
73]
[
4]
/ answers: 1 / hits: 7903
/ 4 Years ago, sun, may 31, 2020, 12:00:00
I have a situation I want to use await in a ternary operator. I want to set a value to either a literal value or the resolve value of a promise, depending on a condition. Hopefully the code below will help describe what I want to do, but I am pretty sure it is not correct so consider it pseudo code.
const val = checkCondition ? literal value : await promiseGetValue();
Where promiseGetValue() returns a promise which resolves to a literal value. What is the correct way to do this?
More From » async-await