Search code examples
node-red

How to access flow/global context in the HTML file of a node in node-red?


I want to populate a drop-down in a node's editor with data available either in the node or flow or global context. I know that UI elements can be modified in oneditprepare function, but I'm not able to access the context here. I've explored all the APIs and documentation without any luck.

Anybody knows how to do this?


Solution

  • Typically, the context is used by the runtime of the flow - it isn't data used for configuration of the nodes at edit time. This is why there's no API for accessing context from the editor.

    The standard model used in Node-RED is for the node to register its own admin http endpoint that can be used to query the information it needs. You can see this in action with the Serial node.

    You can see more details in this previous SO answer - Send data on configuration