Added based on comments
You are actually getting data but if you are logging directly, it returns proxy object in which the data will not be accessible directly, so you need to log the stringified data.
@wire(getActiveMaterials)
wiredpcMaterials({ error, data }) {
if (data) {
this.aidata = data;
// eslint-disable-next-line no-console
console.log('DATA => ', data, JSON.stringify(data));
} else if (error) {
this.error = error;
}
}
Here, although you see Array(0)
in data, you will get the array of records in JSON.stringify(data)
OLD ANSWER
When the component is rendered 1st time, all the wired services are registered and returns the object {data:undefined,error:undefined}
. This is the reason you will always see them (data or error) as undefined on load of page. However, the service will invoke again when it returns the value (apex method return) to data
if success or provide error
value if failure.