# Accessing server side from client side

**URL:** https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022
**Category:** Developing Nodes
**Created:** [3 May 2020 21:08 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022 "2020-05-03T21:08:13Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JasonBSteele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jasonbsteele/32/21181_2.png) [@JasonBSteele](https://discourse.nodered.org/u/JasonBSteele)
#### Post date: [3 May 2020 21:08 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022/1 "2020-05-03T21:08:13Z")

</div>

Hi, I'm new to Node Red an Node.js but I have got a couple of my own Nodes working now so understand the basics.

I have hit a challenge around showing a list of devices in the Node's Properties tab so that one can be selected for that Node. The code to do that is a separate module that is currently included into the server side code so how do I access it from the client side config code so that I can show the list?

I have looked at some examples and they are recreating some of the service access code using $.get or whatever, rather than the separate module. I don't like this very much - it's brittle and not DRY.

Ideally I would expose the separate module to the client side code through the Config Node but I'm not sure how to achieve this.

I am also confused that server side you use `RED.nodes.getNode()` to get a node, but this isn't available client side and you use `RED.nodes.node()` instead.

I guess the way to do this is for the client side/config code to include in my separate module and for me to instantiate it and pass the config token to it?

But for some reason `myConfigNode.credentials.token` doesn't appear to be set after getting `myConfigNode` using `RED.nodes.node(node.configNode)`.

Some pointers on the best practise for this would be much appreciated, preferably with a link to a good example!

Thanks

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [3 May 2020 21:16 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022/2 "2020-05-03T21:16:11Z")

</div>

The default example is the serialport node looking up what ports are available on the server side.. - on the client side the action is here [https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.html#L395](https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.html#L395) which calls the server side endpoint here - [https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.js#L461](https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.js#L461)

---

<div class="post-metadata">

### Author: ![JasonBSteele](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jasonbsteele/32/21181_2.png) [@JasonBSteele](https://discourse.nodered.org/u/JasonBSteele)
#### Post date: [4 May 2020 13:16 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022/3 "2020-05-04T13:16:26Z")

</div>

Ah yes - I see, an endpoint is created using 'RED.httpAdmin.get' for the client code to call.

Can you also offer any understanding on `RED.nodes.getNode()` vs `RED.nodes.node()`?

Are there any docs I can look at that would tell me more?

Thanks

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [4 May 2020 13:24 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022/4 "2020-05-04T13:24:41Z")

</div>

> [@JasonBSteele](#):
>
> Can you also offer any understanding on `RED.nodes.getNode()` vs `RED.nodes.node()` ?

An unintentional inconsistency since the very start of Node-RED.

The key thing to remember is the runtime and editor apis are different - you are accessing different things. In the runtime you will get the runtime node object. In the editor you'll get the node configuration.

---

<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: [3 July 2020 13:24 UTC](https://discourse.nodered.org/t/accessing-server-side-from-client-side/26022/5 "2020-07-03T13:24:42Z")

</div>

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