# Trying to refer to parts in an array without undefined error?

**URL:** https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051
**Category:** General
**Created:** [30 January 2021 14:50 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051 "2021-01-30T14:50:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![edwardr](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@edwardr](https://discourse.nodered.org/u/edwardr)
#### Post date: [30 January 2021 14:50 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051/1 "2021-01-30T14:50:20Z")

</div>

Hello folks,

Coming across a problem I can`t get around,

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca2517597e5962698365cd57f6e37cff68cff5e1.png)

I thought to address the point in a payload it would be msg.payload.data["Number of which you want"]

But it doesnt work ? If I was wanting to address each value in the list seperately what should I do ?

Thank you

---

<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: [30 January 2021 14:52 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051/2 "2021-01-30T14:52:02Z")

</div>

try reversing the order... of those two lines...  
the first one blatts msg.payload... then the second tries to read msg.payload as it was... but it is no longer there.

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [30 January 2021 14:52 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051/3 "2021-01-30T14:52:29Z")

</div>

On line 5 you set msg.payload to an integer, which overwrites msg.payload.data

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [30 January 2021 15:52 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051/4 "2021-01-30T15:52:15Z")

</div>

Also the debug you show says that `msg.payload` is an array, `msg.payload.data` does not exist.

I note that the two error messages in the debug do not come from the same function node, that may or may not be relevant.

---

<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: [10 March 2021 13:22 UTC](https://discourse.nodered.org/t/trying-to-refer-to-parts-in-an-array-without-undefined-error/40051/5 "2021-03-10T13:22:35Z")

</div>

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