Each
The each node serves to execute child nodes repeatedly. Presently, the only nodes allowed as direct children of the each node are email and http_request nodes.
Suppose we aim to send multiple emails individually to different recipients. We can employ the each node to trigger the email node multiple times for this purpose.
In the collect_emails
node, we gather emails and pass them to the each
node using io.each(emails)
. The each
node automatically processes the piped data, evaluating each value in the array individually. Consequently, the send_email
node will execute emails.length
times.
Considering our emails array resembles this structure: emails = [{email: 'johndoe@protokol.io'}, {email: 'joanadoe@protokol.io'}]
, we can utilize placeholders within the send_email
node to facilitate email transmission: