score:1

Accepted answer
export const testFunction = () => {
    return new Promise((resolve, reject) => {
        otherFunction().then(( response ) => {
            //do something...
            resolve(response);
        }).catch(( error ) => {
            //do something...
            reject(error);
        });
    });
}

score:0

const testFunction = () => {
    return new Promise((resolve, reject) => {
        if (error) {
            return reject(error); // this is the value sent to .catch(error)
        }
        return resolve(valueToReturn); // this is the value sent to .then(result)
    });
}

Related Query

More Query from same tag