function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Renato Barucco 11Renato Barucco 11 

ReferenceError: label is not defined at eval

I'm trying to implement a logic for Product Category Status Channel but I'm stuck with this error: ReferenceError: label is not defined at eval.

This is the code I'm developing:

getFilters() {
        var action = initFilters
        var arrExisting = !(this.productsAlreadyInCart === undefined || this.productsAlreadyInCart === null) ? this.productsAlreadyInCart : []
        action({ 
            doInit : true,
            productsAlreadyInCart : JSON.stringify(arrExisting),
            existingFiltersStr : null
        }).then(response => {
            var vals = [
                label.Label_CreateOpportunity, 
                label.Label_ProductSearch, 
                label.Sopping_cart_title, 
                label.Label_AdditionalInformation]
                this.indicatorElements = vals
                this.filterObjs = response.filters
                this.mainObj = response
                this.triggerGetProds = true
                
                if (localStorage.getItem("showSaveSuccess") != null) {
                    this.showSaveSuccess = true
                    var mainObj = this.mainObj
                    
                    mainObj.messageType = 'success'
                    mainObj.messageToDisplay = label.Saved_Date
                    
                    this.mainObj = mainObj
                }
                
                console.log('mainObj ', this.mainObj)
                
                localStorage.removeItem("showSaveSuccess")
            }).catch(response => {
                var errors = response
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        this.showToast(label.ErrorMessage, errors[0].message)
                    }
                    this.error = errors
                    console.log('Errors ', this.error)
                } else {
                    this.showToast(label.ErrorMessage, label.UnknownError)
                }
            })
        }


How canI fix it?

Regards

PriyaPriya (Salesforce Developers) 
Hey,

Kindly refer this for the similar asked :-
https://salesforce.stackexchange.com/questions/273109/lwcreferenceerror-a-is-not-defined-at-eval-eval-at-productfamilyoptions

Thanks
fgwarb_devfgwarb_dev
I was having the same problem so i removed the "label." prefix and it worked fine

Before with error "label is not defined at eval"
import someCustomLabel from '@salesforce/label/c.custom_label_name';

export default class lwc_name extends LightningElement {
 label = {
  someCustomLabel
 };

 someFunction(){
  this.variable = label.someCustomLabel;
 }
}

After no error
import someCustomLabel from '@salesforce/label/c.custom_label_name';

export default class lwc_name extends LightningElement {

 someFunction(){
  this.variable = someCustomLabel;
 }
}