Why does my async function return a Promise instead of a value?
Why the Promise appears
Marking a function as async tells JavaScript to wrap its return value in a Promise. Returning 42 from an async function gives you a Promise that resolves to 42. If you log the call without waiting for it, you see the Promise object instead of the value inside.
The fix depends on where you need the value. Inside another async function, write const result = await getData(). In regular code, attach a callback with then, or call the function from an async wrapper that handles the result.
- Use await inside an async function
- Chain then when you cannot use await
- Log the awaited value, not the call
- Handle rejections with try and catch
Watch for missed awaits
A common gap is calling an async function from a handler without awaiting it. The surrounding code keeps running before the result arrives, so variables look empty. Searching your code for calls to async functions can reveal these gaps quickly.
Check your function signatures too. If a helper is marked async but nothing inside it awaits, callers may still need to handle a Promise even though no real waiting happens.
Common mistakes
- Forgetting await and then reading the result too early.
- Mixing then chains and await in the same block until the flow is hard to follow.
