That's because items and the data are null and you are trying to access a property 'length' of a null value . You can put a check like
if(this.items && this.items.data) {
return (this.items.data.length > 0)
}
return false;
If you set items='';
- It means item is null and console.log(typeof items);
will return an object. Null is an object.
However, if you just declare let items;
and console.log(typeof items);
will return undefined
So if you set items='';
, your original code should work.