# Can you pass data to the HTML file of a node?

**URL:** https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033
**Category:** Developing Nodes
**Created:** [16 November 2020 23:06 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033 "2020-11-16T23:06:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)
#### Post date: [16 November 2020 23:06 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/1 "2020-11-16T23:06:16Z")

</div>

I would like to pass a list to the html file to display it in a dropdown, and pass back the selected item when the node is initialized.  
Is there a way to pass data from the node's js file to the html?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 November 2020 23:16 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/2 "2020-11-16T23:16:57Z")

</div>

> [@Norberg95](#):
>
> Is there a way to pass data from the node's js file to the html?

Yes

inject (set to inject at initialisation) --\> file in --\> _something_ --\> ui\_dropdown

where _something_ is a function or JSON or _other_ node that turns your text into a JS array & sends it in `msg.options` to the ui\_dropdown in the required format as per the dropdown nodes built in help....

> The Options may be configured by inputting `msg.options` containing an array. If just text then the value will be the same as the label, otherwise you can specify both by using an object of `"label":"value"` pairs :  
> `["Choice 1", "Choice 2", {"Choice 3":"3"}]`

---

<div class="post-metadata">

### Author: ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)
#### Post date: [16 November 2020 23:38 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/3 "2020-11-16T23:38:00Z")

</div>

Maybe I was not specific enogh.  
So I embedded node red to my app and now I am creating custom nodes.  
The idea is that tha app is passing data to the the js part([https://nodered.org/docs/creating-nodes/node-js](https://nodered.org/docs/creating-nodes/node-js)) of the custom node and the js sends data to the front-end(the nodes editor page [https://nodered.org/docs/creating-nodes/node-html](https://nodered.org/docs/creating-nodes/node-html)). The data should be there when I am opening the nodes editor page without linking the node to any other nodes.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [16 November 2020 23:44 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/4 "2020-11-16T23:44:13Z")

</div>

Passing the list back to your node's js file is just a matter of including it in the config parameters. Getting a dynamically created list of values into the Editor requires an API call. Easy enough to do in the html file since it includes JQuery. The API is usually done using Node-RED's Express app but if you are running in embedded mode, you will probably have to add a route to the custom ExpressJS API in your own code.

The serial nodes are often quoted as an example of how to do this. Take a look at the code.

My own uibuilder node makes use of several API's in the Editor so that I can pass file contents back and forth and check whether a url has already been used for example.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [16 November 2020 23:45 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/5 "2020-11-16T23:45:13Z")

</div>

Ah my apologies. Yes. But I can't answer from phone right now. Will point you in the right direction tomorrow if someone doesn't give you a heads up in the mean time.

Edit ^ seems Julian is there with am answer as I was typing 🙂

---

<div class="post-metadata">

### Author: ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)
#### Post date: [17 November 2020 00:02 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/6 "2020-11-17T00:02:08Z")

</div>

I guess it was a bad question, not a bad answer. 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [1 December 2020 00:02 UTC](https://discourse.nodered.org/t/can-you-pass-data-to-the-html-file-of-a-node/36033/7 "2020-12-01T00:02:08Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
