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
JeffreyStevensJeffreyStevens 

Lightning Component help - getting data from controller

After completing the trailhead for Lightning components, I'm trying one  in my sandbox now.   I'm missing something, and maybe it's my Attribute in the Component, but I'm not sure?  My output doesn't produce the {!v.Transactions[0].name} field (just the "[Transactions List...]".

Component
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" controller="ctrl_TransactionList">
   
    <aura:handler name="init" action="{!c.doInit}" value="{!this}" />
    
    <div class="slds-page-header" role="banner">
    	<div class="slds-grid">
        	<div class="slds-col">
   				[Transactions List...]<br/>
                <ui:outputText value="{!v.Transactions[0].name}" /> 
            </div>
        </div>
    </div>
    
</aura:component>
Componenet Controller
({
	doInit: function(component, event, helper) {
		console.log('doInit...'); 
        
       
        var action = component.get("c.getTransactions");
        
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            } else {
                console.log("Failed with state: " + state);
            }
        });
        
        $A.enqueueAction(action);
	},
})

Apex Controller
public without sharing class ctrl_TransactionList {
    
    @AuraEnabled
    public static list<Transaction__c> getTransactions() {
        return [SELECT id,name,Payee__r.Name FROM Transaction__c WHERE id = 'a0T2A00000LDUQf'];
    }

}


 
Best Answer chosen by JeffreyStevens
Nithesh NNithesh N
I think you are missing the attribute in the Component. 
Add this above your aura handler (On Line 2).
<aura:attribute name="Transactions" type="Transaction__c[]"/>

And  in your client-controller code (on Line 11), you are setting yoour return value to "v.items" which doesn't exist in your component. 
So, you need to fix it too.

All Answers

Nithesh NNithesh N
I think you are missing the attribute in the Component. 
Add this above your aura handler (On Line 2).
<aura:attribute name="Transactions" type="Transaction__c[]"/>

And  in your client-controller code (on Line 11), you are setting yoour return value to "v.items" which doesn't exist in your component. 
So, you need to fix it too.
This was selected as the best answer
JeffreyStevensJeffreyStevens
Thanks - Yes - I caught those after I posted it. 

So, I changed the v.Items to v.Transactions also.

Thanks