I am using N8N and have access to the Python node.
I have a simple 3 node workflow that runs a SQL statement, gets a list of Amazon ASINs back (pretty much IDs) and now I would like to pass those into the Python function below.
I am running into a couple errors…
I am getting an error: ERROR: ModuleNotFoundError: No module named ‘requests’
I can see the next error is going to be around passing ASIN from the previous node into the print statement to return the result.
As n8n does use Pyodide underneath the hood, which does not support the request module, does sadly n8n neither. So, I suggest using the HTTP Request Node to make HTTP requests.
Regarding your second question, assuming you have Mode: Run Once for Each Item set, you should actually be able to see the answer in the default code of a Code node.
The default code is:
# Add a new field called 'myNewField' to the JSON of the item
_input.item.json.myNewField = 1
return _input.item
Meaning assuming the “ASIN” is saved as asin on the item, you can access it via _input.item.json.asin.