function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
M B 33M B 33 

Getting error when calling doInit from Lightning Component

I have a Lightning App that contains some components.
For one component calling doInit() does not work.

I get following error message :
Action failed: c:BoatSearchResults$controller$doInit [component is undefined] Failing descriptor: {c:BoatSearchResults$controller$doInit}

This is the component and controller :
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes"  
                controller="BoatSearchResults"
 >
    
        <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    
</aura:component>
({
    doInit: function (component, event, helper) {
        helper.onSearch();
    }
})





 
Best Answer chosen by M B 33
Hemant_SoniHemant_Soni
Hi,
Can you please put you helper.js as well reson is because error comes for helper.
Thanks
Hemant

All Answers

Hemant_SoniHemant_Soni
Hi,
Can you please put you helper.js as well reson is because error comes for helper.
Thanks
Hemant
This was selected as the best answer
M B 33M B 33
({
    onSearch: function (component, event, helper) {                   
        var action = component.get("c.getBoats");
        action.setParams({ boatTypeId : component.get("v.boatTypeId") });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var boatItems = response.getReturnValue();
				component.set("v.boats", boatItems);
            }
        });
        $A.enqueueAction(action); 
    }
})

 
M B 33M B 33
I solved it Thanks. The signature of the helper was incorrect and I was not transimitting the component when calling the helper from the controller
Mohamed Aref 5Mohamed Aref 5
hii MB33 i have the same issue . what do you mean by the signature o the helper is incorrect ?