In the following code, return
does not return the awaited value. What can I so the the promise will be resolved before returning. Hence I want result
to be SUCCESS
instead of a promise.
const foo = async()=>{
try{
let a = await new Promise((resolve)=>{
resolve('SUCCESS')
})
console.log("this is inside the try block");
return a
}catch{
console.log('error')
}
}
let result = foo();
console.log(result);