Connecting nodes correctly

Connecting nodes correctly. I have created my first real workflow. It is very complicated. I noticed that with every HTTP request query, the previous node, which is before the HTTP request, for example the code node, is not transferred with the data via HTTP request. That is why I have added merge everywhere. Am I doing something wrong here, or do you know of a better solution?

Yes, the node only outputs the processed data, not the input data. Instead of using all these merge nodes, you can just refer to that node data with this format:
below example is for the “Loop Over Items” node. Make sure you name it exactly how you name it in your workflow.
{{ $(‘Loop Over Items’).item.json.row_number }}

Alternatively, you can just collapse the nodes on the input side, and can just drag that value from that specific node to your target node and it will automatically write it in the format above.

Hi @Mikail_Horoz

That’s a great question, and it’s a problem everyone faces when they start building complex workflows!

You are right that the HTTP Request node replaces the incoming data with its own output (the API response). Your solution of using a Merge node is correct, but there is a much easier way.

The Better Solution: Use the Node’s Built-in Merge Option

Almost every node in n8n, including the HTTP Request node, has a setting to automatically merge the data for you. This will let you delete all those extra Merge nodes.

Here’s how to do it:

Click on your HTTP Request node.
Go to the Options tab at the top.
Find the Include in Output field.
Change it from Append to Merge by Position .

Now, the node will automatically combine the data it received as input with the data from the API response. Your workflow will become much cleaner and easier to manage. You can apply this setting to all of your HTTP Request nodes.

If you found this answer helpful, please consider marking it as the solution and giving it a like

Hello, I had exactly the same problem before, but then there are issues with the loop process. Because we keep retrieving the item again and again. That’s why I bypassed it.

Hello, could you tell me exactly which option I need to activate for this? Thank you very much for your help!

or here?

For items within a loop, you need to get items from the loop node instead of taking it from the switch node or the first node. This way, for each loop cycle, it will change the data accordingly. From what I can see in the provided image, the data should reach the loop node without being affected so inside the loop, you can refer to that data items via the loop node items just as I showed you in the example in my previous comment.
In your case, If you include the workflow instead of the image, I can pinpoint exactly how to effectively reference data in each node instead of using the merge nodes.
For example: you are merging the data of https request node with the output of the first code node and then sending it to the next code node but you don’t need to do that, because you can just reference the variable in the second code node with this format:
{{ $(‘your exact node name’).item.json.variable_name }}
if the variable name includes spaces then it should also be written as:
{{ $(‘your exact node name’).item.json[‘variable name‘] }}

Hope this helps. Let me know if you need further help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.