[Vuejs]-Access to nested object property

0๐Ÿ‘

โœ…

Due to a possibility of a data in the Employees array containing an null value in the employee_function (for example the employee_function object contained a null value instead of an object), it may cause the type error in which you are trying to read an null object.

The easiest way to solve this is by adding a ? in front of the attribute you are referencing the object from. For example employee_function?.name. This means that if the employee_function is null, it will not read any attributes that is connected to the code.

0๐Ÿ‘

schedule.employee_function.name should be enough, regarding your v-for and the structure of your data.

Leave a comment