When I have a promise, I usually do something like:
funcPromise()
.then(()=> {
// some stuff happens
return value; // what if there's nothing to return here?
})
.then(()=> { //...
})
.catch(err=>log(err));
But if there's nothing to return, should i do return Promise.resolve()
or return null
, or simply return;
?? I know that in a one-liner, the arrow function has implicit return, but for my case, it's a multi-statement function.
It doesn't matter.
If you have no return
statement (or a return
statement with no value), the function will return undefined
, resulting in a promise of undefined
.
That is presumably fine for you.
The promise actually returns an object that has a value if you call the right method. Maybe that helps?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With