Course contentsShow
← JavaScript
Lesson 1384 of 2,72330. Async/AwaitFree lesson

Forgetting the 'await' Keyword

Learn why omitting 'await' returns a pending Promise instead of the resolved value, causing subtle bugs.

Forgetting the 'await' Keyword

You'll learn why omitting await before an async operation silently returns a pending Promise object instead of the resolved value, creating hard-to-debug issues.

The Problem

When you call an async function but forget to use await, JavaScript doesn't throw an error. Instead, it immediately returns a Promise object—often still in a pending state. Your code continues executing, but you're working with a Promise wrapper instead of the actual value you expected.

Think of it like ordering food delivery: If you call the restaurant (async function) but don't wait for the delivery (await), you get a tracking number (Promise) instead of your actual meal. You can't eat a tracking number!

What Actually Happens

async function fetchUserData() {
  return { name: "Alice", age: 30 };
}

async function processUser() {
  // WRONG: Missing await
  const user = fetchUserData();
  console.log(user.name); // undefined - user is a Promise!
  console.log(user); // Promise { <pending> }
  
  // CORRECT: Using await
  const actualUser = await fetchUserData();
  console.log(actualUser.name); // "Alice"
}

Without await, user is a Promise object, not the user data. Accessing user.name gives undefined instead of throwing an error—making this bug sneaky and hard to spot.

Why It's Dangerous

This mistake is silent. Your code runs without errors, but produces incorrect results. You might see undefined, [object Promise] in strings, or unexpected behavior in conditionals when checking Promise objects instead of their resolved values.

Key Takeaway: Always use await when calling async functions if you need the resolved value. Without it, you get a Promise wrapper, not the actual data—causing subtle bugs that are easy to miss.