Variable set outside a loop is inaccessible

My HTTP request needs a session token in the body to authenticate.
The session token is in $node[“Init”].data[“session”]

On the first iteration, everything works fine. On the second iteration, the session token isn’t there. How can I set a variable thats accessible everywhere?

The problem is the small green number you see in the corner of the nodes. Nodes use always the data of the same iteration. So if a node executions the first time it uses the data of the first iteration of the previous nodes. If a node gets executed the second time, it uses the data of the second iteration of the previous nodes. In this case, does the node outside of the loop only execute once. So if you access the data outside of the loop it will not find any, as the node does not have a second iteration.

So the only way to make that work is to either move the init-node into the loop itself or keep on passing it around through the flow.


Hello @jan – is there any plan to create some “global” variables that would be reachable inside the loop (and solve situations like this)? I have no problem using functions for this, but some people around me struggle. I haven’t found anything in #feature-requests, so I’m sharing this might be an interesting insight. :wink:

All the best!


Hi @honzapav, this doesn’t exist yet I am afraid, but there are a few feature requests and active discussions around this: Variables defined in function node are not holding values on 0.198.2 - #17 by Roney_Dsilva

Seeing this thread is almost three years old and a lot has changed since, I shall close this one but please do share your thoughts on the existing feature requests.

1 Like