Promise Creation

const promise = new Promise((resolve, reject) => {
  if (success) resolve(data);
  else reject(error);
});

Promise Methods

promise.then(data => console.log(data));
promise.catch(error => console.error(error));
promise.finally(() => console.log("Done"));

Async/Await

async function fetchData() {
  try {
    const data = await fetch(url);
    return await data.json();
  } catch (error) {
    console.error(error);
  }
}

Common mistakes / Pitfalls

  • People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
  • It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
  • Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026