Explore Library
Code Quiz

Missing await on async result

Spot why an async function returns a Promise instead of the expected value.

Codejavascript
async function getUser(id) {
  const res = await fetch(`/api/users/${id}`);
  return res.json();
}

function showName(id) {
  const user = getUser(id);
  console.log(user.name);
}

showName(1);

What is the bug in this code, and how should it be fixed?