Obtaining a seated value from a JSON array on a localhost website

#1

I have set up a localhost website on a windows 10 computer and I wish to serve the JSON array to an HTTP node in node red. Whilst I can access the ip address index file from the HTTP node okay I am unsure how I drill down to obtain items in the array. Localhost is as below;
image

And current node set up worth [""0""].Channel being the path to the array item when I hover over the first item in the list.

Any help would be greatly appreciated.

0 Likes

#2

The HTTP Request node's URL field can use the mustache syntax to insert msg properties into the url.

The sidebar help for the node says this:

When configured within the node, the URL property can contain mustache-style tags. These allow the url to be constructed using values of the incoming message. For example, if the url is set to example.com/{{{topic}}} , it will have the value of msg.topic automatically inserted. Using {{{...}}} prevents mustache from escaping characters like / & etc.

The key thing is the use of the {{ }} to indicate where the message property should be inserted.

So for your url, you'd want to use:

http://192.168.1.121/{{payload[0].Channel}}/Channel
0 Likes

#3

Thanks Nick,

Unfortunately that didn't work and the same error message was returned.

0 Likes

#4

Does the index.php file need to format the JSON output to Mustache template for the HTTP url GET method to work?

0 Likes