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
awaitkeyword before an async function callCalled 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
async function getData() {
return fetch("/api").then(r => r.json());
}
const data = getData();
console.log(data); // [object Promise]async function getData() {
return fetch("/api").then(r => r.json());
}
const data = await getData();
console.log(data); // actual resultgetData() 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 missedawaitCheck the function signature — does it return a Promise?
Verify the calling function is
asyncif you're usingawait
How to fix
Add
awaitbefore the async function callMake the calling function
asyncif it isn't alreadyUse
.then()instead ofawaitif you can't make the function async
How to prevent
Use
async/awaitconsistently and enable ESLintrequire-awaitruleCheck return types — if a function returns a Promise, you need
await
Related Resources
Related Lessons
- Async JavaScript
Learn about async/await and Promises
Related Practice
- Predict the Function Call Result
Practice predicting function call results.