# If exists objects

**URL:** https://discourse.nodered.org/t/if-exists-objects/839
**Category:** General
**Created:** [15 June 2018 21:03 UTC](https://discourse.nodered.org/t/if-exists-objects/839 "2018-06-15T21:03:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)
#### Post date: [15 June 2018 21:03 UTC](https://discourse.nodered.org/t/if-exists-objects/839/1 "2018-06-15T21:03:36Z")

</div>

Hi!

I have this  
payload.Response.Appointment  
or  
payload.Response.Objects this…

if i do a test like if ( msg.payload.Response.Objects == null ){

i get an error, whatr am i doing wrong???

---

<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: [15 June 2018 21:07 UTC](https://discourse.nodered.org/t/if-exists-objects/839/2 "2018-06-15T21:07:59Z")

</div>

Without sharing the error you are getting it is very hard to say what is wrong.

---

<div class="post-metadata">

### Author: ![RogierQ](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rogierq/32/3211_2.png) [@RogierQ](https://discourse.nodered.org/u/RogierQ)
#### Post date: [15 June 2018 21:09 UTC](https://discourse.nodered.org/t/if-exists-objects/839/3 "2018-06-15T21:09:55Z")

</div>

Sorry… thought it would be clear what i do wrong…  
The error i get is  
“TypeError: Cannot read property ‘0’ of undefined”

---

<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: [15 June 2018 21:12 UTC](https://discourse.nodered.org/t/if-exists-objects/839/4 "2018-06-15T21:12:56Z")

</div>

An error of `“TypeError: Cannot read property ‘0’ of undefined”` means you are trying to access a property called `0` of something that is undefined.

The only example properties you have mentioned are `payload.Response.Appointment` and `payload.Response.Objects` - neither of which mention `0`.

So, I think you need to share a bit more detail of what you’re doing.

---

<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: [15 June 2018 21:21 UTC](https://discourse.nodered.org/t/if-exists-objects/839/5 "2018-06-15T21:21:36Z")

</div>

If you are trying to determine whether a property of an object exists then use `hasOwnProperty("property_name")`. So for example

```auto
if (msg.payload.Response.hasOwnProperty("Objects"))

```

will tell you whether msg.payload.Response has a property of that name.
