Skip to main content
Anurag Pareek ha fatto una domanda in #Lightning Experience
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 risposte
  1. 16 feb 2015, 07:10
    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.