Node-Red Http 请求节点输出
Node-Red Http Request Node Output
我有一个功能节点可以为 msg.payload 提供 IP 地址。
而且这个 IP 地址永远不会相同。
它从提供 IP 地址的功能节点转到 HTTP 请求节点。
然后 HTTP 请求节点必须对指定的 IP 地址执行某些操作。
在我的 HTTP 请求节点中,我使用了这个
http://+{{msg.payload}}+/control?cmd=GPIO,1,1
因为msg.payload总是不同的。
它不起作用。
我做错了什么吗?
+{{msg.payload}}+
因为我尝试了以下方法:
{{msg.payload}}
{{{msg.payload}}}
+{{msg.payload}}+
其中 none 似乎有效。
请帮忙
来自 http-request
节点的信息边栏:
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
要使用小胡子语法将 msg.payload
包含在 url 中,您需要执行以下操作:
http://{{payload}}/control?cmd=GPIO,1,1
或者您可以将 URL 字段留空,然后使用键 url
.
通过 msg 对象传递整个 URL
例如在 http-request
节点之前的 function
节点设置以下内容:
msg.url = "http://" + msg.payload + "/control?cmd=GPIO,1,1";
return msg;
我有一个功能节点可以为 msg.payload 提供 IP 地址。 而且这个 IP 地址永远不会相同。 它从提供 IP 地址的功能节点转到 HTTP 请求节点。 然后 HTTP 请求节点必须对指定的 IP 地址执行某些操作。 在我的 HTTP 请求节点中,我使用了这个
http://+{{msg.payload}}+/control?cmd=GPIO,1,1
因为msg.payload总是不同的。
它不起作用。
我做错了什么吗?
+{{msg.payload}}+
因为我尝试了以下方法:
{{msg.payload}}
{{{msg.payload}}}
+{{msg.payload}}+
其中 none 似乎有效。
请帮忙
来自 http-request
节点的信息边栏:
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
要使用小胡子语法将 msg.payload
包含在 url 中,您需要执行以下操作:
http://{{payload}}/control?cmd=GPIO,1,1
或者您可以将 URL 字段留空,然后使用键 url
.
例如在 http-request
节点之前的 function
节点设置以下内容:
msg.url = "http://" + msg.payload + "/control?cmd=GPIO,1,1";
return msg;