What is a Promise in JavaScript — and what Promise pending means

You asked AI to write a function that queries a model and returns the answer. You run it, print the result — and the console says:
Promise { <pending> }
No error, no text. This is where almost everyone assumes the code is broken. It isn't. You just got a receipt instead of the parcel — and that's exactly what a Promise is.
A Promise is a receipt, not an answer
Here's the thing: some operations aren't instant. A model request, reading a file, a trip to the database — they all take time. Your program can't stand there waiting; it would freeze solid.
So JavaScript pulls a trick. It immediately hands you a Promise — a receipt object that means "no answer yet, but I commit to bringing you one." The program runs on, and you're holding the receipt.
A real-life analogy: you check your coat at the cloakroom and get a numbered tag. The tag isn't the coat. But it gets you the coat when the time comes. Promise { <pending> } in your console is you printing the tag and wondering why it doesn't smell like a coat.
This is part of a bigger topic — async. The Promise is its central object.
Three states
A receipt has exactly three states, and you can read them right in the console:
- pending — "waiting." The request went out, no answer yet.
- fulfilled — "done." The result is inside.
- rejected — "didn't work out." An error is inside: network dropped, bad key, server returned 500.
The transition happens once and for good. A Promise can't change its mind and go back to pending.
await — "claim it with the receipt"
There's exactly one word that fixes Promise { <pending> }:
// before: a receipt in the console
const answer = askModel("Hi");
console.log(answer); // Promise { <pending> }
// after: the answer in the console
const answer = await askModel("Hi");
console.log(answer); // "Hi! How can I help?"
await says: "stand here until the receipt is redeemed." The function you write await inside has to be marked async.
A rule for life: if you see
Promise { <pending> }in the console, you forgot anawait. Nine times out of ten that's the whole diagnosis.
The trap everyone hits
This is the one that actually loses people's data. You have ten questions and want ten answers:
// does NOT do what you think
const answers = questions.map(async (q) => await askModel(q));
console.log(answers); // [Promise, Promise, Promise, ...]
map honestly returned an array — an array of receipts, not answers. Each inner function is async, and map has no idea how to wait for them. Then you save that to a file and get ten lines of [object Promise].
One line fixes it:
const answers = await Promise.all(
questions.map((q) => askModel(q)),
);
Promise.all takes a stack of receipts and returns a stack of contents — once they all arrive. Bonus: the requests go out at the same time, not one after another. Ten two-second model calls take two seconds, not twenty.
Promise.all has one trait worth knowing up front: it fails entirely if a single receipt fails. Fire ten model requests, have one trip over a rate limit, and you've lost all ten answers — including the nine that worked.
When that's not what you want, there's a twin:
const results = await Promise.allSettled(
questions.map((q) => askModel(q)),
);
// [{ status: "fulfilled", value: "..." }, { status: "rejected", reason: ... }]
allSettled waits for everything and reports honestly on each one: this worked, this didn't. You keep the nine answers and retry the tenth.
One more detail that saves an evening: forEach can't wait at all. Put an await inside a forEach and the loop dutifully runs to the end having waited for nothing. Use a plain for...of — await works there.
Where you'll meet Promises daily
Basically anywhere your code talks to the outside world:
fetch(...)— any call to an API, model requests included.- Reading and writing files.
- Database queries.
- Delays, timers, image loading.
A special case is streaming a model's reply. There the Promise hands back a stream rather than finished text, and chunks arrive as they're generated. That's why chat answers "type themselves" on screen.
What to take away
A Promise is a promise of a value, not the value. Three states: waiting, done, failed. await unwraps it, async lets you write await, and Promise.all redeems a stack of receipts at once.
And most of all: Promise { <pending> } isn't an error — it's a message saying "you printed the tag." The word await turns the tag into the coat.
Is a Promise the same thing as async/await?
No. A Promise is an object; async/await is convenient syntax for working with it. People used to write .then(...), now they mostly write await — but underneath it's the same Promise.
Why is my await underlined in red?
You're probably writing await inside a regular function. It only works inside a function marked async (or at the top level of a module). Add async before function and the squiggle goes away.
What do I do if a Promise fails?
Wrap the await in try / catch — the error lands in the catch block. Without it the failure flies off to the console as an "unhandled rejection" and your user sees a blank screen instead of a clear message.
The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.





