Question on Code node, how to handle two input of one code node?

Describe the problem/error/question

I get hot posts from reddit by get many posts node(NODE A) and get posts comment from reddit using getting post comment node(NODE B). when I want to Combine Post & Comments using code node, I find code node cannot line two node SEPERATELY BUT in a point. GEMINI said it is wrong with my n8n.

What is the error message (if any)?

I want combine the comment and the post.

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version:1.91.3
  • Database (default: SQLite):SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • Operating system:Debian

gemini said that the code need have input0 and input1

Please share your workflow in a code block. There is a way to use the merge node to line up records based on a condition.

Thank you for you reminder. I post it.

the question is that code node only have one point to input even I connect two node to code node. THERE IS NO INPUT0 INPUT1. How to handle two input for one code node, so I can combine post and comment?

  • The code in your Code node (Step 6) has been replaced with the complete code provided above.
  • The Code node (Step 6) indeed has two input connection lines.
  • The output of the Split Out node (Step 4) is accurately connected to the first input port (Input 0) of the Code node (Step 6).
  • The output of the Code (Process Comments) node (Step 5b) is accurately connected to the second input port (Input 1) of the Code node (Step 6).
  • The workflow has been saved and activated. THE CODE NODE has two connection lines but without input0 input1

The very last code node will effectively be executed twice, each with different input data. You might have over-complicated your workflow. If you want to combine the two lists, then I would suggest using the merge by condition. Otherwise if you want to do it by code, the way you can access previously executed nodes, is by referencing them by name like this:

So from the Process Comments code block you can reference the data output of the filter node with $('Filter & Prep Posts').first().json

thank you for you reply. I am not a dev and would you please share me some relative workflow in a simple way to combine the post and comment in reddit?

See if this works? I didnt really change your code nodes much as I didnt want to disturb your mappings

1 Like

Great, thank you for your help. Is there any solution only use merge or other node to combine the submission and its’ comments? using code node seems a little difficulty to me .