Async Functions Return Promises
You'll learn that async functions always return Promises, which means you can consume them with .then(), .catch(), and .finally() just like any Promise.
The Core Idea
Even though async functions let you write asynchronous code that looks synchronous with await, they're still built on Promises under the hood. Every async function automatically returns a Promise, regardless of what you explicitly return from the function body.
This means you have two ways to consume async functions:
- Using
awaitinside another async function - Using
.then()and.catch()like a traditional Promise
Both approaches work because async functions are Promises.
Why This Matters
Sometimes you can't use await (like at the top level of older code, or in callbacks). In these situations, you can treat the async function exactly like any Promise-returning function:
async function fetchUser(id) {
if (id < 0) throw new Error('Invalid ID');
return { id, name: 'Alice' };
}
// Consuming with .then() and .catch()
fetchUser(42)
.then(user => console.log('Got user:', user))
.catch(err => console.error('Error:', err.message));
// Still returns a Promise!
fetchUser(-1)
.catch(err => console.log('Caught:', err.message));
This interoperability makes async functions incredibly flexible—you can use them in existing Promise chains without any special conversion.
Key Takeaway: Async functions always return Promises, so they can be consumed with .then(), .catch(), and .finally() anywhere you'd use a regular Promise, giving you flexibility in how you handle asynchronous operations.