[Vuejs]-Getting undefined property from Ajax response nested object


What I expect is causing the error is for some individual message, message.recipient is undefined. In the case that a recipient is undefined, when you try to access the name property of the recipient as you do here,


Javascript will throw an error because you are now trying to get the name property of undefined.

You can protect yourself against that error using a guard.

{{message.recipient && message.recipient.name}}

Leave a comment