September 4, 2020

undefined error @wire in LWC in Salesforce

This error usually happens when cacheable=true is not set in the apex method. Check the below code that works without any issues since cacheable is set correctly.

public class AccountListController {
    
    @AuraEnabled(cacheable=true)
    public static List < Account > fetchAccts() {
        return [ SELECT Id, Name, Industry, Type FROM Account LIMIT 10 ];
    } 

}

No comments:

Post a Comment