Search code examples
javascripthtmljsonnode-red

Node-red websocket and http request


I am trying to visualize the information of a JSON object in an HTML page, the information is taken through a WebSocket and then outputted using HTTP in and HTTP out nodes.

My problem is that I am not really sure what nodes to use after the HTTP/in the node in order to parse through the object and output the information in table form in an HTML page.

The JSON object looks like this:

[  
{  
  "Name":"asa",
  "Country":"ny",
  "Index":"48",
  "Status":"ok",
  "Speed":"2.3",
  "Direc":"83",
  "PublishTime":"2018-04-15 15:00",
  "Latitude":"25.129167",
  "Longitude":"121.760056"

Flow so far


Solution

  • You need to look at using the Context to store the data from the Websocket input (the HTTP-Request node us for making HTTP requests to remote servers, not for linking with the HTTP-In/Out nodes in the flow).

    You can use a Change node or a Function node to store and retrieve values from the Context. E.g. One in the WS flow to store and one in the HTTP flow to recover the data.

    Once you have the data in the context, you can use the built in Template node to format the data. Or if you want the tableify you seam to already have installed.