4👍
This doesn’t really have anything to do with Vue. You’re dealing with a javascript error here. You can’t reference a property of a null/undefined variable. The easy way around this is to use the && operator to check for the object.
someObj && someObj.property
If someObj is falsy, the right side is never evaluated. Note that when the left side is truthy, && returns the right side. Details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators
If you want a specific blank value, you can do this
someObj ? someObj.property : "Default value"
- [Vuejs]-Dockerized Vue SPA with different API urls depending on where it is running
- [Vuejs]-How to make every object property reactive?
Source:stackexchange.com