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]

1 Answer 1

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

You must log in to answer this question.

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