Promise (Node.js)
A Promise represents the eventual result of an asynchronous operation. It starts pending and later settles as fulfilled (with a value) or rejected (with an error), and you react with .then(), .catch(), and .finally().
Node.js
Promises replaced the messy nesting of callbacks with a chainable object. An async function returns a Promise; you attach .then(value => ...) for success and .catch(err => ...) for failure. Because each .then returns a new Promise, you chain steps in a flat, readable sequence instead of nesting them.
A Promise is in one of three states: pending (not done), fulfilled (resolved with a value), or rejected (failed with a reason). Once settled it never changes. Combinators handle groups: Promise.all waits for all to fulfill (or rejects on the first failure), Promise.allSettled waits for every outcome, and Promise.race settles with the first to finish.
Promises are the foundation that async/await builds on — await simply pauses for a Promise to settle. Always handle rejections (with .catch or try/catch around await); an unhandled rejection can crash the process in modern Node.
Syntax
doAsync().then(v => ...).catch(e => ...);Examples
JavaScript
const fs = require("fs/promises");
fs.readFile("data.txt", "utf8")
.then(text => console.log("length:", text.length))
.catch(err => console.error("failed:", err.message));