# Getting undefined error in flow.get

**URL:** <https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582>\
**Category:** General\
**Created:** [3 March 2020 20:17 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582 "2020-03-03T20:17:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GravityRZ](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@GravityRZ](https://discourse.nodered.org/u/GravityRZ)\
**Post date:** [3 March 2020 20:17 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582/1 "2020-03-03T20:17:17Z")

</div>

Hello,

i work with flow.get and global.get a lot  
however i get an error in the currrent flow but do not see anything wrong

de output is undefined but it should state up (the value of network.192.168.1.25.ipstate

i suspect that the ipaddress having dots is causing the problem but how to solve this

flow including function

`[{"id":"88454dc9.c905c","type":"inject","z":"b26f44fa.693c68","name":"","topic":"","payload":"192.168.1.25","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1800,"wires":[["2bee791b.798fe6"]]},{"id":"dab0419c.cded2","type":"debug","z":"b26f44fa.693c68","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":1800,"wires":[]},{"id":"2bee791b.798fe6","type":"change","z":"b26f44fa.693c68","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":1800,"wires":[["62491705.0074d8"]]},{"id":"62491705.0074d8","type":"function","z":"b26f44fa.693c68","name":"","func":" var ip = msg.topic;\n var status = flow.get('network.'+msg.topic+'.ipstate')\n msg.payload = status\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1800,"wires":[["dab0419c.cded2"]]}]`

data in flow

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/4258d7729edbbc1c774eb5ba87b869ab2947582b.png)

---

<div class="post-metadata">

**Author:** ![techraf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/techraf/32/17389_2.png) [@techraf](https://discourse.nodered.org/u/techraf)\
**Post date:** [3 March 2020 20:34 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582/2 "2020-03-03T20:34:49Z")

</div>

Here you are:

```auto
status = flow.get('network')[msg.topic]["ipstate"];

```

---

<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:** [3 March 2020 20:38 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582/3 "2020-03-03T20:38:18Z")

</div>

The problem comes because you are trying to use `192.168.1.25` as part of the key name.

The full key you function code generates is

```auto
'network.'+msg.topic+'.ipstate'

```

which results in:

```auto
'network.192.168.1.25.ipstate'

```

It doesn't recognise `192.168.1.25` as a single key name, rather it interprets that as the four distinct object property levels.

The fix is to either generate a key like:

```auto
'network["192.168.1.25"].ipstate'

```

using:

```auto
'network["'+msg.topic+'"].ipstate'

```

or as @techraf suggests, get the whole `network` object first and then pull out the bits you need.

---

<div class="post-metadata">

**Author:** ![GravityRZ](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@GravityRZ](https://discourse.nodered.org/u/GravityRZ)\
**Post date:** [3 March 2020 20:38 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582/4 "2020-03-03T20:38:34Z")

</div>

thanks, almost tried everything (including using ) but sometimes i just can not get it right.

---

<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:** [17 March 2020 20:50 UTC](https://discourse.nodered.org/t/getting-undefined-error-in-flow-get/22582/5 "2020-03-17T20:50:41Z")

</div>

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