Fetch Backend Data in Foreground

Hi,

I like to fetch an environment variable in oneditsave() and wonder if this is possible. I think that the problem is, that we're on the browser, but need to get data from the NR-flow.

Something like:

//...
oneditsave: function () {
	// ...
	const e = $env.get('VARIABLE');
	// ...
}

Is there a straightforward way?

You can add an admin endpoint in node-red (server-side) (in the JS) and call it from the front end (in the html script).

Look at the source for the serial node (and others) that already do this.

I'm on my lunch, so dropping by...

To enforce the above by @Steve-Mcl, here is what I do for my z-wave module:
Here is an http endpoint, that returns serial ports :

Then in my node html (oneditprepare)

1 Like

uibuilder also has several examples and they are broken out into separate functions for convenience along with error handling and user-notification where needed.

Cool, works like charm. A little bit painful to search all these source code for solutions. :wink:

Maybe fresh eyes could document it and submit a PR against the node-red docs? :wink:

1 Like

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