Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.
Hi all,

          While working on my lightning components, one error is coming .  Is there anybody who can help me out ?

Error-  Cannot read property 'push' of undefined.

here is the sample of Helper.js

({

    createBAccount : function(component,BAccount) {

        this.upsertExpense(component, expense, function(a) {

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

            BAccount.push(a.getReturnValue());

            component.set("v.BAccount", BAccount);

            this.updateTotal(component);

        });

    },

    upsertExpense : function(component, BAccount, callback) {

        var action = component.get("c.saveBAccount");

        action.setParams({

            "BAccount": BAccount

        });

        if (callback) {

            action.setCallback(this, callback);

        }

        $A.enqueueAction(action);

    },

})

The bold one is  getting an error over here .
3 answers
  1. Feb 16, 2015, 7:10 AM
    Hi Anurag,

    I don't know much about the lightning component, but from the error and code what I can tell is that "BAccount" is undefined in your CreateBAccount function. check from where the function is being called and see if that's passing the correct value.

    Regards,

    Vivek Patel.
Loading
0/9000