I'm using getListUi wire adapter to get listViews of an object and trying to put it into a picklist. But I'm getting the following error.
render threw an error in 'c:showListView' [LWC component's @wire target property or method threw an error during value provisioning. Original error: [Cannot read property 'lists' of undefined]]
This is the code:
import { LightningElement,wire,api,track } from 'lwc';
import PRODUCT_OBJECT from '@salesforce/schema/Product2';
import { getListUi} from 'lightning/uiListApi';
export default class ShowPicklistValues extends LightningElement {
@track selectedValue;
@track allListViews;
@wire(getListUi, {objectApiName: PRODUCT_OBJECT})
wiredlistView({error,data}) {
this.allListViews = data.lists;
var listViewData = [];
for(var i=0;i<this.allListViews.length;i++){
listViewData.push({"label" : this.allListViews[i].label, "value" : this.allListViews[i].apiName});
}
this.allListViews = listViewData;
}
handleChange(event) {
this.value = event.detail.value;
}
}
What am I doing wrong here?