79259935

Date: 2024-12-07 04:09:09
Score: 0.5
Natty:
Report link

How to Avoid It

Simply return the existing promise without wrapping

Example:

function getStuffDone(param) {
    return myPromiseFn(param + 1);
}

If additional logic is neede

function getStuffDone(param) {
    return myPromiseFn(param + 1)
        .then((val) => {
            
            return val;
        });
}

Avoid creating a new Promise or deferred object unless absolutely necessary. Leverage chaining and existing promises instead.

Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): How to
  • Low reputation (0.5):
Posted by: Avnish Jayaswal