extract host name of the node-red host, with JS ?

1,042 views
Skip to first unread message

Jéan Roux

unread,
Jun 2, 2017, 4:00:55 PM6/2/17
to Node-RED
Hi, can I get the host name of the underlying server to nodered with Javascript, that I can use in a function node? I tried 
msg.payload = location.host ;


as per normal JS, but this does not work?


Dave C-J

unread,
Jun 2, 2017, 4:17:52 PM6/2/17
to node...@googlegroups.com
one way is to include the "os" library in the functionGlobal section of your settings.js
    os:require('os')
then you can use a function node with something like
  msg.payload = context.global.os.hostname();

Jéan Roux

unread,
Jun 2, 2017, 4:26:29 PM6/2/17
to Node-RED
Tx Dave.
Reply all
Reply to author
Forward
0 new messages