I was looking at this question asked and the answer makes sense
What is the explicit promise construction antipattern and how do I avoid it?
However if you just want to simply put a log message in the function or something simple is there any way of avoiding having to create a new promise like this
function getStuffDone(param) {
return new Promise(function(resolve, reject) {
// using a promise constructor
myPromiseFn(param+1)
.then(function(val) {
console.log("getStuffDone executing");
resolve(val);
}).catch(function(err) {
console.log("getStuffDone error");
reject(err);
});
});
}
And what if you also wanted a log message before the promise gets run in this position? Does this make things more difficult?
function getStuffDone(param) {
return new Promise(function(resolve, reject) {
// using a promise constructor
console.log("getStuffDone starting");
myPromiseFn(param+1)
.then(function(val) {
console.log("getStuffDone executing");
resolve(val);
}).catch(function(err) {
console.log("getStuffDone error");
reject(err);
});
});
}