Skip to content

Promise Not Awaited

Quick summary

You called an async function without `await`, so you got a Promise object instead of the actual result you expected.

Why this happens

  • Forgot the await keyword before an async function call

  • Called an async function in a non-async context without .then()

  • Assigned the result of an async call to a variable and used it as a value

Minimal example

✗ Broken code
async function getData() {
  return fetch("/api").then(r => r.json());
}
const data = getData();
console.log(data); // [object Promise]
✓ Fixed code
async function getData() {
  return fetch("/api").then(r => r.json());
}
const data = await getData();
console.log(data); // actual result

getData() returns a Promise — without await, data is the Promise object, not the resolved value.

How to diagnose

  • Log the result — if it shows [object Promise], you missed await

  • Check the function signature — does it return a Promise?

  • Verify the calling function is async if you're using await

How to fix

  • Add await before the async function call

  • Make the calling function async if it isn't already

  • Use .then() instead of await if you can't make the function async

How to prevent

  • Use async/await consistently and enable ESLint require-await rule

  • Check return types — if a function returns a Promise, you need await

Related Resources

Related Lessons

Related Practice

← Back to language