I am making an api call where a property may or may not exist. My first thought was wrapping that in a ternary statement would fix this issue, however, it is not.
newObject.fax_from = value.from.phoneNumber === 'undefined' ? 'none' : value.from.phoneNumber;
When the property this not exist in the api return data, I get a message that
TypeError: Cannot read property 'phoneNumber' of undefined
any ideas?
I even tried to be more specific such as
newObject.fax_from = value.from.phoneNumber = typeof( value.from.phoneNumber) == 'undefined' ? 'none' : value.from.phoneNumber;