1

Hi While executing the the JS file i am getting below error.

    {
        @track abc = [];
        if (data) {
              let currentData = data.fields;
              this.abc.push({
                value: data.fields.Static__c.value,
                key: 'Static__c'
            })
        }       
        const trs = this.abc.get("Static__c");
    }

getting below error:

[this.abc.get is not a function]
4

abc is an array, not a map. You cannot use get to get value in array of object. You have to use Array.find

var staticKeyElement = this.abc.find(ele => ele.key === 'Static__c');
console.log(staticKeyElement.value);

Sample Playground link : https://developer.salesforce.com/docs/component-library/tools/playground/K_PlRylL/1/edit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.