Callback hell
suggest changeCallback hell (also called the pyramid of doom) arises when many asynchronous callbacks are nested. Modern Node.js code uses promise-based APIs and async/await to keep the control flow flat:
const contents = await readRegularFile(filename);
console.log(contents.trim());
Hello from Node.js!
Promise-based core APIs also preserve errors as rejected promises, so callers can handle them with try/catch or .catch().
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents