Promises vs Async/Await: Writing Cleaner Async JavaScript

Every JavaScript developer reaches a point where callbacks stop working and something cleaner has to take over. That something is usually a promise, and then, a little later, async and await. The debate around promises vs async await is not really about which one is better in some absolute sense. Both are the same machinery underneath, and async functions return promises. The real question is which shape makes your code easier to read, easier to debug, and easier to change six months from now. This guide compares them with runnable code, so you can see the difference instead of taking someone’s word for it.

What a Promise Actually Is

A promise is an object that stands in for a value that does not exist yet. It starts in a pending state, then settles into one of two states: fulfilled, with a value, or rejected, with a reason. You attach handlers with .then() for the success path and .catch() for the failure path, and the promise calls the right one when it settles. Nothing about this blocks the rest of your program. The code after the call keeps running while the work happens in the background.

Here is a promise doing the simplest possible job, waiting one second and then delivering a value:

function wait(ms) {
  return new Promise((resolve) => {
    setTimeout(() => resolve("done"), ms);
  });
}

wait(1000).then((value) => {
  console.log(value); // "done"
});

The important detail is that wait returns immediately. The value shows up later, inside the .then() callback. If you want to understand why the timing works this way, the guide on how the JavaScript event loop actually works explains the queue that makes promises resolve in the order they do.

How Async/Await Changes the Shape

Async and await do not replace promises. An async function always returns a promise, and await pauses that function until a promise settles. The difference is purely in how the code reads. Instead of nesting callbacks inside .then(), you write lines that look sequential, and the engine handles the waiting for you.

The same one-second wait, written with async and await:

async function run() {
  const value = await wait(1000);
  console.log(value); // "done"
}

run();

Read those two versions side by side and the trade becomes clear. The promise version says “when this finishes, do that.” The async version says “wait for this, then do that.” For five steps in a row, where each step needs the result of the last one, the async version stays flat while the promise version grows a chain.

Promises vs Async Await: The Same Task in Two Styles

Take a realistic job: fetch a user, then fetch that user’s orders, then add up the total. With promises and chaining, each step hands its result to the next .then(). With async and await, the same steps read like ordinary lines of code. Both versions are correct, and both handle errors, but one of them is easier to scan at 2 a.m. when something breaks in production.

// Promises with chaining
fetchUser(42)
  .then((user) => fetchOrders(user.id))
  .then((orders) => orders.reduce((sum, o) => sum + o.total, 0))
  .then((total) => console.log("Total:", total))
  .catch((error) => console.error("Failed:", error));
// Async/await
async function showTotal(userId) {
  const user = await fetchUser(userId);
  const orders = await fetchOrders(user.id);
  const total = orders.reduce((sum, o) => sum + o.total, 0);
  console.log("Total:", total);
}

showTotal(42).catch((error) => console.error("Failed:", error));

Notice that the async version still needs a .catch() somewhere, because an async function returns a promise and a rejected promise with no handler is an unhandled rejection. JavaScript promise chaining is compact when the steps are simple transformations, and it shines when you want to attach handlers from different places. The async version wins when the steps involve conditions, loops, or intermediate values that several later steps need, because those values stay in plain local variables instead of being threaded through a chain.

Side-by-Side Comparison

Aspect Promises Async/Await
Reading style Chain of callbacks, reads bottom-up in long chains Flat, top-to-bottom, reads like synchronous code
Intermediate values Must be passed along or stored outside the chain Stay in local variables, easy to reuse
Error handling One .catch() at the end of the chain try/catch blocks, same as the rest of the code
Loops and conditions Awkward, often needs helper functions Plain for loops and if statements
Parallel work Promise.all() reads naturally Still needs Promise.all() underneath
Debugging Stack traces can jump across callbacks Stack traces usually point at the awaited line

Error Handling: .catch() vs try/catch

Async await error handling looks familiar because it uses the same try/catch you already use for synchronous code. That familiarity is a real advantage. A .catch() at the end of a long chain catches everything, which is convenient, but it can also hide which step failed. A try/catch around a single await tells you exactly which call broke, and you can wrap different steps in different blocks when they need different recovery.

async function loadDashboard(userId) {
  try {
    const user = await fetchUser(userId);
    return user;
  } catch (error) {
    console.error("Could not load user:", error.message);
    return null;
  }
}

Two mistakes show up constantly. The first is forgetting to handle the rejection at all, which leaves an unhandled rejection warning and, in Node.js, can crash the process. The second is wrapping a whole function body in one giant try/catch and then guessing which line failed. Keep the blocks small and name the failure in the log message. When you build a REST API with Node.js and Express, this habit pays off fast, because a route handler that returns a clear error beats one that swallows the cause and returns a bare 500.

Running Work in Parallel

The most common performance mistake with async and await is awaiting things one at a time when they do not depend on each other. If three requests are independent, awaiting them in sequence takes the sum of their times. Starting all three first, then awaiting them together with Promise.all(), takes roughly the time of the slowest one. Promise.all parallel requests are the pattern to reach for whenever the tasks are independent.

async function loadProfile(userId) {
  const [user, orders, settings] = await Promise.all([
    fetchUser(userId),
    fetchOrders(userId),
    fetchSettings(userId)
  ]);
  return { user, orders, settings };
}

Watch the failure mode here. If any one of the promises rejects, Promise.all() rejects right away and the other results are discarded, even if they already finished. When you need every result no matter what, use Promise.allSettled() instead and check each result’s status.

When Plain Promises Still Win

Async and await is the better default for most application code, but plain promises still win in a few places. When you need to start work now and attach the handler later, a promise object is what you pass around. When you are writing a small utility that transforms one value into another, a short .then() chain is less ceremony than an async wrapper. When you are combining many promises with Promise.all(), Promise.allSettled(), or Promise.race(), you are already working with promises directly, and forcing an async wrapper around the combination adds nothing.

Mistakes That Make Async Code Hard to Read

The first mistake is awaiting inside a loop when the iterations are independent. Each await waits for the previous one, so a loop over twenty items runs twenty round trips in sequence. The second mistake is mixing styles in one function: half a chain, half awaited lines. Pick one shape per function and keep it consistent, because a reader should not have to switch mental models halfway down.

Frequently Asked Questions

Is async/await faster than promises?

No. Async functions are built on promises, so the work takes the same time either way.

Do I still need to learn promises if I use async/await?

Yes. Async and await is syntax on top of promises, and every error message, library return value, and combinator like Promise.all() is a promise. You cannot debug async code well without knowing what a promise is doing underneath.

Promises vs async await is a choice of shape, not a contest. Promises give you the object that represents work in progress, and async and await give you the cleanest way to write sequences of that work. Learn promises first, write sequences with async and await, reach for Promise.all() when tasks are independent, and keep error handling close to the call that can fail. When you are ready to put this into a real project, the walkthrough on deploying a Node.js app to a VPS with PM2 and Nginx shows how async server code behaves once it is running on a live machine.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.