Lesson 17 / 28

Promises in Node

A cleaner shape for async results, with built-in Promise-based APIs.

Native Promise APIs

Many built-ins now ship a Promise-based version directly — no wrapping needed.

import { readFile } from "node:fs/promises";

readFile("notes.txt", "utf8")
  .then((data) => console.log(data))
  .catch((err) => console.error("Failed:", err.message));

Promise.all for parallel work

Promise.all runs several async operations concurrently and waits for all of them to finish.