I’m wondering in which code it makes more sense, is there any point in returning the promise like this if the promise does not contain a value:
async function action () {
// let's say there are many such lines with await before returning
await asyncFunction()
// will return Promise that does not contain any value!
return anotherAsyncFunction()
}
// action().then(myAnotherAction)
Or it would be wiser to do so:
async function action () {
await asyncFunction()
await anotherAsyncFunction()
}
// const result = await action()
The first option is to use only when returning some value?
Otherwise, it is easier to use the second option, because it is easier to add another action with "await" to the end of the function?
async function action () {
await asyncFunction()
await anotherAsyncFunction()
// easy to add another function, no need to touch "return"
await andAnotherAsyncFunction()
}