Janvier123
Janvier123

Reputation: 31

Node Red output as JSON via HTTP

I want to call node red HTTP page, like node_red_url:1880/test and have a json formatted output back, like:

{"result": [{"Type": "Temp","Data": "30.0 C","id": "31"}]}

Data will be pulled from a MQTT node

is this possible? Ive found a static page, but i cant to find out how to add dynamic data to it https://cookbook.nodered.org/http/serve-json-content.html

Upvotes: 0

Views: 722

Answers (1)

hardillb
hardillb

Reputation: 59648

Yes it's perfectly possible. You just have to realise that the MQTT delivery has to be totally separate from the HTTP request.

MQTT-in -> function node to store latest value in the context

HTTP In -> function node to retrieve value from context -> HTTP Response node

Upvotes: 0

Related Questions