Missing await in async function
Spot why an async function logs a pending Promise instead of the fetched value.
Codejavascript
function getUser() {
return new Promise((resolve) => {
setTimeout(() => resolve({ name: 'Ada' }), 100);
});
}
async function showUser() {
const user = getUser();
console.log(user.name);
}
showUser();What is the bug in this code?