I am getting a Proxy object instead of an actual component attribute. I saw the question and it did not help me.

Here is my code:

campingApp.app :

<aura:application >

camping.cmp :

<aura:component >

campingHeader.cmp :

<aura:component >
    <h1>Camping List</h1>

campingList.cmp :

<aura:component >
        <li>Bug Spray</li>
        <li>Bear Repellant</li>
        <li>Goat Food</li>

campingListItem.cmp :

<aura:component >
    <aura:attribute name="item" type="Camping_Item__c" required="true" default="{ 
                        'sobjectType': 'Camping_Item__c',
                        'campingItemName': 'SSSSSSSSSSSSSSSSS',
                        'price__c': 0,
                        'quantity__c': '555555',
                        'packed__c': false }"/>
        <lightning:formattedNumber value="{!v.item.price__c}" style="currency"/>
        <lightning:formattedNumber value="{!v.item.quantity__c}"/>
    <lightning:input type="toggle"                            
                         label="Packed: "                           
                         checked="{!v.item.packed__c}" />
    <lightning:button label="Packed!"

campingListItemController.js :

    packItem : function(component, event, helper) {
        var item = component.get("v.item");
        console.log("item.quantity__c: " + item.quantity__c);
        item.packed__c = true;
        component.set("v.item", item);

        var button = event.getSource();
        button.set("v.disabled", true);

Here is the console after previewing the campingApp.app and the Packed! button being clicked:

enter image description here

My main purpose here is to set the item.packed__c to true and update all the places where it is used. I can do that with these lines:

item.packed__c = true;
component.set("v.item", item);

But before these lines I should have the components attribute named item in the item variable. I am trying to achieve this by the following line:

var item = component.get("v.item");

But as you can see instead of the item I am getting some weird Proxy object which really do not provide me any kind of access to the underlying item.

What am I doing wrong here?


1 Answer 1


The best solution I found for this is to do the following:

const objUncovered = JSON.parse(JSON.stringify(objWhichIsCoveredWithProxy));

You must log in to answer this question.

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