+ Start a Discussion
Athira VenugopalAthira Venugopal 

Issue in server side Apex controller

I am working on Lightning aura components. The problem is in my servide side apex controller, its not returning the expected result. Te result is [Object,Object]


<aura:component controller = "BoatSearchResults" implements="flexipage:availableForAllPageTypes" access="global" >
   <aura:attribute name="boats" type="Boat__c[]"/>

     <lightning:layout multipleRows="true">
           <lightning:button variant="brand" label="Search" onclick="{! c.searchBoat }" aura:id="SearchButton" />
        <aura:if isTrue="{!v.boats.length > 0}">
            <aura:iteration items="{!v.boats}" var="bot">
                <lightning:layoutItem  size="3" flexibility="grow" class="slds-m-around_small">
                    <c:BoatTile boat="{!bot}" />
            <aura:set attribute="else">
                <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">
                    <ui:outputText value="No boats found" />

js file

       searchBoat : function(component, event) {
            let action = component.get("c.getBoats");
            action.setCallback(this, function(response){
            let state = response.getState();
            if (state === "SUCCESS") {
                console.log('TEST ' + response.getReturnValue());//  this ouput is [Object, Object]
                component.set("v.boats", response.getReturnValue());


public with sharing class BoatSearchResults {
    public static List<Boat__c> getBoats() {
     return [select id,Name,BoatType__c,Contact__c,Picture__c from Boat__c];


<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="boat" type="Boat__c"/>

    <lightning:button class="tile">
        <!-- Image -->
        <div style="{!'background-image: url(\'' + v.boat.Picture__c + '\')'}" class="innertile">
            <div class="lower-third">
                <h1 class="slds-truncate">{!v.boat.Name}</h1>

Danish HodaDanish Hoda

console.log(JSON.stringify(response.getReturnValue())); to check the result you are getting

Hi Athira,

This is not the issue with the server-side apex controller.

console.log('TEST ' + response.getReturnValue());//  this ouput is [Object, Object]

Here you are trying to concatenate object and string.

To show output, simply stringify the return value like:


I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
Athira VenugopalAthira Venugopal
Thanks Danish and Sachin. Now I am able to check the result. But why my BoatTile.cmp is not getting rendered On selecting the boattype, I need to show the images of boats in BoatTile.cmp
Athira VenugopalAthira Venugopal
it is showing the boats length, I printed it inside 'Matching Boats'