Consider the following code:
const getName = () =>
new Promise(resolve => setTimeout(resolve, 1000, 'xxx'));
f = async () => {
let name = await getName();
console.log(name);
return name;
}
console.log(f());
The function will wait before printing "name" but it will still return the promise instead of the result and won't print the correct output outside the function. Is there a way around this?