Can't get data for expression after Code block

Block after code does not access previous node variables.

In the last node of the bellow example, i need to get info of the SetVars block, but it cannot be accessible.

Problem in node HTTP Request Can’t get data for expression

This is the workflow, simplified to avoid sensible data sharing.

Share the output returned by the last node

[ERROR: Can’t get data for expression]

Information on your n8n setup

  • 1.22.6
  • Database (default: SQLite):
  • Docker
  • Ubuntu Server

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @DRauber, welcome to the community!

First of all, thanks a million for sharing a workflow that makes it easy to reproduce the problem. It makes it so much easier to understand and solve such problems.

Now for the problem itself, this ultimately comes down to the expression you have in use here. An expression like $('Node name').item will use a technology called item linking (or sometimes “paired items”). This allows n8n to identify the related item from a previous node, even if the order or number of items has changed along the way. n8n nodes implement this by attaching meta data to each item they receive and pass on. For this to work with the Code node, the metadata would have to be provided by your code (documented here).

However, seeing you have only a single item, it might be much easier to use a slightly different expression instead of updating your custom code in multiple nodes. If you go with {{ $('SetVars').first().json["url"] }} n8n will always read the first (and only) item from your SetVars node without the need for any data about linked items. You can find a full list of available expressions here.

This is how it looks in a workflow:


Hope this helps :slight_smile:


Thanks for you @MutedJam!

Now it is ok :grinning:

1 Like

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