HTTP Get with dynamic variable ?

776 views
Skip to first unread message

Trieu Le

unread,
Oct 15, 2015, 11:07:27 PM10/15/15
to Node-RED
Dear all,
I'm a newbie with Node-RED, I have some issues hope everybody help me.
I want to send some dynamic variables to "HTTP in" node with GET method, Please let me know how can i do it ?
-> I want to get value 12
Thanks & best regards !

Dave C-J

unread,
Oct 16, 2015, 3:51:22 AM10/16/15
to node...@googlegroups.com
the msg.req.query contains any parameters passed on the get...

http://{my_pi_address}:1880/test?variable=12
will give you an object {variable : 12}


here is a simple example

[{"id":"b25523b4.4daae","type":"http in","name":"","url":"/test","method":"get","swaggerDoc":"","x":317,"y":523,"z":"ecf4c734.130b38","wires":[["f62aa1fb.09d56"]]},{"id":"125b643f.eda49c","type":"http response","name":"","x":646,"y":510,"z":"ecf4c734.130b38","wires":[]},{"id":"f62aa1fb.09d56","type":"function","name":"","func":"console.log(msg.req);\nmsg.payload = \"OK\";\nmsg2 = {payload:msg.req.query};\nreturn [msg,msg2];","outputs":"2","noerr":0,"x":471,"y":548,"z":"ecf4c734.130b38","wires":[["125b643f.eda49c"],["4718d87f.b8e728"]]},{"id":"4718d87f.b8e728","type":"debug","name":"","active":true,"console":"false","complete":"false","x":661,"y":562,"z":"ecf4c734.130b38","wires":[]}]

Trieu Le

unread,
Oct 16, 2015, 4:10:27 AM10/16/15
to Node-RED

Hi Dave C-J,

I got your flow and try to run it, but it not working for me, The picture below show error !

Can you please point me what is my wrong ?

Thanks & best regards ! 


Nicholas O'Leary

unread,
Oct 16, 2015, 4:15:08 AM10/16/15
to Node-RED Mailing LIst
Hi,

Dave's example was http://{my_pi_address}:1880/test?variable=12

You have missed the ?variable part in that screenshot.

Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Trieu Le

unread,
Oct 16, 2015, 4:23:00 AM10/16/15
to Node-RED
Hi Nick O'Leary,
Thank for your reply !
I got it and it's working now.
Thanks all so much !

Hi,

Dave's example was http://{my_pi_address}:1880/test?variable=12

You have missed the ?variable part in that screenshot.

Nick

- show quoted text -
- show quoted text -
Reply all
Reply to author
Forward
0 new messages