Node variable showed undefined on execution for HTTP Request when connected to a Item Lists node

Describe the problem/error/question

I intend to loop the HTTP Request based on the number of Item Lists, there are 2 in my case.
image

Whilst the node variable preview showed the expected value, but on execution it showed as “undefined”. If I type it as fixed value it works, of course the other headers would failed until I typed it which isn’t what I want to do.

As a test, there is no problem if the HTTP Request node was called before the Item Lists node.

image

Is there a bug in the Item List node?

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Unfortunately this is still a problem with version 0.222.3.

Hi @engowen

Your grant type is probably only available on the first item not the second. So you would need to make sure to always grab the first item’s value for that field. Or to add the value to the second item.

Hi @BramKn, the node variables are referring to an earlier node and has been working end to end but failed when I slot an item lists node in between for a valid reason. Since preview was showing the expected result, I don’t understand why the variable value not passing to HTTP Request.

Hi @engowen

Like I said, there is no value on the second Item.
There is a value on the first, so that goes fine. But when you split the items there is a second Item that doesn’t have a value.
When looking back a few nodes it uses the index of the item, which doesn’t exist in the node before it so it is undefined.
I already gave you 2 possible solutions, so please have a look at that.

Hi @BramKn , thanks for the explanation. I did a few test and confirm there isn’t any node variable value from the 2nd iteration onward. However I’m still struggling to get it work. Using the sample workflow below

can you show how to make reference to “always grab the first item’s value for that field”? The expected the result is

Thanks.

Use {{ $('<nodeName>').first().json.<fieldName> }}

Tried but not working.

alternatively tested with (0)

The loop should have access to the previous node variable values regardless of first or second iteration.

U are using [ ] not ( ) like I showed in the example…

2 Likes

Brilliant! Thanks for spotting my mistake and patience in guiding towards the solution. It works great and I can continue to develop my work further. Thanks again!

1 Like

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