This is my first post here. Im just starting with n8n.
I have an issue in code node.
The input pane on the left show me
“No fields - item(s) exist, but they’re empty” after I test the code node,
However prior testing when I just double click on the node the value is visible.
Is the node not executed because not connected wiith the triger? Well even if I connect it, it does not work.
Here is the code in the code node:
import json
a = json.loads(_input.all()[1]["json"]["param"])
raw_data = json.loads(_input.all()[0]["json"]["redditdata"])
author = "LilFingaz" # na stałe
comments = raw_data[1]["data"]["children"]
comment = next((c for c in comments if c["data"]["author"] == author), None)
if not comment:
return {"json": {"error": f"Comment by author {author} not found"}}
item = {
"author": comment["data"]["author"],
"body": comment["data"]["body"],
"id": comment["data"]["id"],
"upvotes": comment["data"]["ups"]
}
return {"json": item}
i think its something simplei have not understood yet. thank you
What is the error message (if any)?
Please share your workflow
Sorry it is my first post. When I paste my workflow i get error posting, it says body is to long. Please guide eme.
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
This approach doesn’t work as expected. The Node param is never executed, and it doesn’t pass the parameters to the Code Node. n8n processes the workflow step by step, moving from the start to the end. If additional parameters are required, a Node needs to be added in between the other Nodes.
This is only possible when the param node is connected as shown by Franz. If you connect it like in your screenshot, it never gets executed and you cannot reference the output data in your code node.
Use the “Include Other Input Fields” and access the data from previous node like you already did in your code example.
Yes, I understand. I did connect it as he sugested but still no luck/understanding how does python syntax has to look inside the code node.
perhaps i got myself confused with to complex start. I should first understand how to assign variables in python from fields in set nodes.