Hi there! I’m pretty new to n8n but already enjoying working with it. What I want to do is to merge data from 2 different inputs: one input comes from a “loop over items” node (input 1) and the other input is static (fetched once and never changes through cycles) comes from a code node (input 2). I want to merge input 2 with input 1 on every loop cycle. The problem that I’m having is that the merge is done only for the first cycle, and the other cycles output the data just from input 1, without merging. I want to solve this issue.
I suspect that this is due to the nature of how the merge node works: it waits for the 2 inputs to be available. This is done for the first cycle, but for the rest of the cycles, it seems that the merge node detects both inputs are already available, and does the merge without considering input 2. But this is just what I think.
What is the error message (if any)?
This is the output for the first cycle of the loop. As you can see, the data object (input 2) is appended to the output.
Hi @moosa ! Thanks for replying. I’ll give more details. The problem that I’m having is that the code node output is only been merged on the first loop cycle. The output images show it clearly, but I can clarify. For example, I have this data that is run through the loop node (input 1 of the merge node)
And this data in the code node output (input 2 of the merge node)
{"data": "some_data"}
I expect that the merge loop appends the data of input 2 with input 1 on each of the array runs, so that I get different outputs on each run like this:
{ "name": "Joe"}, {"data": "some_data"} // run 1
{ "name": "Jane"}, {"data": "some_data"} // run 2
{ "name": "Paul"}, {"data": "some_data"} // run 3
But instead, I’m getting the data of input 2 appended only on the first run, and the outputs look like this
{ "name": "Joe"}, {"data": "some_data"} // run 1
{ "name": "Jane"} // run 2
{ "name": "Paul"} // run 3
Thanks @jabbson ! This solved the issue. Also, instead of appending, I ended up using Combine (as shown in your solution + All Possible Combinations). Thanks for the help!