# Cannot read property '0' of undefined

**URL:** https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371
**Category:** General
**Created:** [2 July 2020 11:19 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371 "2020-07-02T11:19:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)
#### Post date: [2 July 2020 11:19 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/1 "2020-07-02T11:19:49Z")

</div>

Dear nodered Experts,

I have this simple function that gets the value of msg.payload and loop through that value to get specific data, how ever I am having an error of "Cannot read property '0' of undefined.

I don't know how this happen. Anyone has already encountered this?  
This is my function:  
 ![funct](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/2/82c5a5137d52ba8621f85dc8949fceecd2965c63.jpeg)

And this is the output of the debug node:  
 ![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/9582ff2f0fdcac1a751ecaa52dadf59a3255ff57.jpeg)

The second message is actually my data on which I like to loop on.

Thank you. I hope you can help me in here.

With kind regards,  
Henjoe

---

<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: [2 July 2020 11:24 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/2 "2020-07-02T11:24:15Z")

</div>

tag is just the iterator - so you probably want  
`payload: tags[tag].value[0]`

---

<div class="post-metadata">

### Author: ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)
#### Post date: [2 July 2020 11:36 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/3 "2020-07-02T11:36:38Z")

</div>

Hello Sir dceeyjay,

I never knew about this, it is now working !  
Thank you very much!

WIth kind regards,  
Henjoe

---

<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: [2 July 2020 11:42 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/4 "2020-07-02T11:42:26Z")

</div>

Yes this isn’t python 🙂

---

<div class="post-metadata">

### Author: ![Henjoe](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henjoe/32/52335_2.png) [@Henjoe](https://discourse.nodered.org/u/Henjoe)
#### Post date: [2 July 2020 11:45 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/5 "2020-07-02T11:45:33Z")

</div>

Yeah! the struggle of using different languages 😃

---

<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: [16 July 2020 11:45 UTC](https://discourse.nodered.org/t/cannot-read-property-0-of-undefined/29371/6 "2020-07-16T11:45:43Z")

</div>

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