How to access the outputs of a multi-output node?

Hi everybody,
I have a trigger node with more than one output:

		inputs: [],
		outputs: ['main', 'main'],
		outputNames: ['data', 'error'],

When I connect a node to the error output I can’t find a way to use its value: it’s not accessible from the expressions, even if it’s visible in the ui:

- the expression was filled in by clicking on the message entry in the left hand side.
data works fine.
I noticed the same behavior when using a switch node: only the data of the first output is accessible.
Any suggestion on how to access the data?

Some details: I am trying to add some customization to EmailReadImap’s check email so that the user can provide their own conditions.
Because of this, it is possible that an error is thrown during the execution of the async GetMail function and I have to catch it because otherwise it will result in an unfulfilled promise and the user won’t have any indicator that something is wrong.
Since I have no way of propagating the error in the usual way (the trigger function has returned already when this happens) I thought to add a second output that will receive the error data if it happens.


Welcome to the community @remoremorali!

That can be done with $items(nodeName?: string, outputIndex?: number, runIndex?: number).

const firstOutput = $items("IMAP Email", 0);
const secondOutput = $items("IMAP Email", 1);

Here the documentation

Doh! A perfect case of RTFM, one may say :slight_smile:
Thanks for your kind reply!

Happy that I could help!

Have fun!