JavaScript Producing Promises

Advice

Use [JavaScript Async Functions](JavaScript Async Functions) instead of this.

Syntax

const p = new Promise(
    function (resolve, reject) { // (A)
        if (true /* replace true with your own logic */) {
            resolve(value); // success
        } else {
            reject(reason); // failure
        }
    });

Related

  • [JavaScript Promises](JavaScript Promises)