Promise-super-basic-example-transform-values-with-Promise.md
February 15, 2023 · View on GitHub
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"));
}
});