Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 350 Bytes

Promise-super-basic-example-transform-values-with-Promise.md

File metadata and controls

14 lines (12 loc) · 350 Bytes

First note the first-principle constructor of a Promise - How to create and make a function that returns a Promise

const createdPromise = new Promise((resolve, reject) => {
  // do a thing, possibly async, then…

  if (/* everything turned out fine */) {
    resolve("Stuff worked!");
  }
  else {
    reject(Error("It broke"));
  }
});