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???
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???
Without sharing the error you are getting it is very hard to say what is wrong.
Sorry… thought it would be clear what i do wrong…
The error i get is
“TypeError: Cannot read property ‘0’ of undefined”
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.
If you are trying to determine whether a property of an object exists then use hasOwnProperty("property_name")
. So for example
if (msg.payload.Response.hasOwnProperty("Objects"))
will tell you whether msg.payload.Response has a property of that name.