I have a simple Apex and LWC @wire to access Custom Metadata Type (CMT) record:


    public static MyCustomMetadataType__mdt getMyCMTRecord(){
            MyCustomMetadataType__mdt myRecord = MyCustomMetadataType__mdt.getInstance('My_Record');
            return myRecord 
        catch (Exception e) {
            System.debug(LoggingLevel.ERROR, 'Exception with message: ' +e.getMessage() );
            throw new AuraHandledException(e.getMessage());


import { LightningElement, api, track, wire } from 'lwc';
import getMyCMTRecord from '@salesforce/apex/My_Handler.getMyCMTRecord'; 


wiredCMTRecord({ error, data }){
        this.cmtRecord = data;
        error = undefined;
        console.log('Data: ' +this.cmtRecord ); //It's not getting printed. 
    } else if(error){
        this.cmtRecord = undefined;
        console.log('Error: ' +error);

I am unable to get the data assigned to my JS property: cmtRecord. I don't see any error logs either.

1 Answer 1


When i am running your code i am getting error

"Error: {"status":500,"body":{"message":"Apex methods that are to be cached must be marked as @AuraEnabled(cacheable=true)"},"headers":{}}"

Apex methods for wire call must be cacheable = true. please update your apex method to have @AuraEnabled(cacheable=true)

Edit: also use JSON.stringify() to see actual data/result , otherwise it will come as [object,object]

console.log('Data: ' +JSON.stringify(this.cmtRecord) );

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .