this.loadData().then(response => {
if (response && response.data && response.data.users && response.data.users.length) {
this.usersLocal = response.data.users
}
})
try .. catch
this.loadData().then(response => {
if (
response
&& response.data
&& response.data.users
&& response.data.users.length
) {
this.usersLocal = response.data.users
}
})
Object.prototype.hasOwnNestedProperty = function(propertyPath){
if (!propertyPath) {
return false;
}
let properties = propertyPath.split('.');
let self = this;
for (let i = 0; i < properties.length; i++) {
var prop = properties[i];
if (!self || !self.hasOwnProperty(prop)) {
return false;
} else {
self = self[prop];
}
}
return true;
};
let response = {data: {users: {}}}
response.hasOwnNestedProperty('data.users');