Post Data into http

Hello,
I cant find out how to post data into http site, that is created with template node.

I get a simple true value of my plc. Now I would like to post this true value into my html page instead of "test" in the

tag.

I guess the JSON node will not be enogh, I need a function node. But I dont know where to start.

In template node replace text with {{payload}}

Yes I did it so far, but now it says on the html site: [oject Object]

Post the flow as can not see whats wrong with no info.
Also a debug of the http in nodes output.

Hi @sfedo

At the moment you have two entirely separate flows

  • one that gets the data from the serial port
  • one that listens for requests to /test and returns some HTML content

If you want to include data from the serial port on the HTML page you need some way to link the two.

We have a recipe in the cookbook for exactly this scenario: Include data captured in another flow : Node-RED

It stores the data into flow context in one flow which allows the other flow to retrieve the most recent value.

@knolleary Wow great answer, thank you. It does exactly what I was looking for. Now I can continue to work with it.

To notice for myself: if I extract data from a different source, for example a plc, I need to "store" it first and then inject into html page right?

Technically you can store it in memory and retrieve it when someone vists the web page.

Or, you can read the serial port on demand whenever web page is visited.

Both have different pros/cons

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