Getting Started with JavaScript Promises and async/await
Stop guessing about asynchronous JavaScript — a clear mental model for Promises, the event loop, and modern async/await syntax.

Asynchronous code is where JavaScript trips up the most people. The good news is that
once you build one solid mental model, Promise chains and async/await both fall
into place.
A Promise is a value that resolves later
A Promise represents a value that isn’t available yet. It is always in one of three
states: pending, fulfilled, or rejected.
const promise = fetch('https://api.example.com/posts');
promise
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));
Each .then() returns a new promise, which is what lets you chain operations without
nested callbacks.
async and await are syntax sugar
async/await does not replace Promises — it is a cleaner way to write them. An async
function always returns a Promise, and await pauses that function until a Promise
settles:
async function getPost(id) {
try {
const response = await fetch(`/api/posts/${id}`);
if (!response.ok) throw new Error('Request failed');
return await response.json();
} catch (error) {
console.error(error);
}
}
Think of
awaitas “give me the value when it’s ready, but don’t block the rest of the program.” The event loop keeps running while the function waits.
A few rules that prevent most bugs
awaitonly works insideasyncfunctions.- An
asyncfunction always returns a Promise — even if you return a plain value. - Errors in
asyncfunctions can be caught withtry/catch, just like synchronous code. - Run independent promises in parallel with
Promise.allinstead of awaiting each one in sequence.
Once these rules feel natural, asynchronous JavaScript stops being scary and starts being one of the language’s most powerful features.
Newsletter
Learn with me
Join the newsletter to receive my latest articles. No spam, unsubscribe anytime.
You'll get a confirmation email. Check your inbox to complete your subscription.
About the author

Abdullah Islam
Abdullah Islam is a computer networking learner, tech blogger, and enthusiast who shares simple, practical guides to help others understand networking concepts and build real-world skills.
Comments