ERROR: Can’t get data for expression when splitting items in loop

Describe the problem/error/question

I was trying to implement API pagination, and I found a behavior that I do not understand, and I suppose it might be a bug.

In Node HTTP request, there is a reference to a variable defined in Edit Fields which is before the loop. It can be any variable, for example, the API URL.
During the execution of the second iteration, Node HTTP request does not have access to the variable defined in Edit Fields.
The error does not occur when there is no node in the loop that splits the data from the HTTP request.
The error also does not appear if the variable is redefined in the first Code node in the loop.

I attach example workflow.

The error message:

ERROR: Can’t get data for expression under ‘URL’ field

Example workflow

Information on your n8n setup

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

Hi @pavvel :wave: Can you try having the set node just before the HTTP node, and let me know if that fixes this up for you?

Hi @EmeraldHerald
Yes that fixes the error, but this is not exactly what I need because the values defined in set node I need in both Code and HTTP nodes.

hi @pavvel

I suppose the problem is with that part: {{ $('Edit Fields').item.json.limit }} in the HTTP node

As the reference item is located before the loop, it has only one item. And if the looped HTTP node has more than one item (or is being executed more than one time), then it won’t know what the next $('Edit Fields').item is. Try to replace it with {{ $('Edit Fields').last().json.limit }}


Hi @barn4k
It is working. Thanks for support.

1 Like

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