I am trying to understand a block of code here, which I believe is redundant code, which could be deleted but maybe I am wrong, here is the code:
return(
myModule.getSomething(args.url)
.then(stream => module.uploadData({
param1: args.param1,
param2: args.param2,
param3: stream,
}))
.then(() => myBroker.dispatch({
queueUrl: myQueueUrl,
payload: JSON.stringify(args.payload),
})
)
.then(msgInfo => {}) . //This line can be removed right?
.catch(error => {
myBroker.dispatch({
queueUrl: anotherQueueUrl,
payload: JSON.stringify({ type: 'error', payload: `[ERROR] ${error}` }),
});
throw error;
})
);
I believe the line:
.then(msgInfo => {})
can be deleted right? the arrow function does nothing, the msgInfo is something that the previous then clause returns after calling myBroker.dispatch, and because of that, I could remove the line I mentioned right?
Can someone give me a clear explanation on this? Why that line exists? Or explain why can't I delete it?
PS: the function getSomething and uploadData returns a promise, the dispatch function I am not so sure because it looks like this:
return(
client.sendMessage(parameters).promise()
.then(data => data)
);
It returns only a object which is 'data' right? or does it return a promise as well, because it contains the then clause in the end?
This syntax notation using multiple 'then' and arrow functions confuses me,
Thanks a lot in advance!