JS promise

const promise = new Promise((resolve, reject) => {
    // do a thing, possibly async, then…
    resolve("Stuff worked!")
    // or
    reject(Error("It broke"))
})

promise.then(
    result => {
        console.log("Success:", result)
    },
    error => {
        console.log("Error:", error)
    }
)