+ Start a Discussion
Justin BreseeJustin Bresee 

Why am I getting this error: This page has an error. You might just need to refresh it. afterRender threw an error in 'c:siteExaminers_v2' [Cannot read property 'Name' of undefined] Failing descriptor: {c:siteExaminers}

I am trying to create a lightning component that pulls some contacts from my salesforce. 

Here is the HTML
<template for:each={examiners.data} for:item='examiner'>
    <tr key={examiner.Id}>
        <th>{examiner.Name}</th>
        <th>{examiner.Title}</th> 
        <th>{examiner.Account.Name</th>
    </tr>
</template>

Here is the javascript
 
import { LightningElement, wire } from 'lwc';
import getSiteExaminers from '@salesforce/apex/Dynamic_Pages.getSiteExaminers';

export default class SiteExaminers extends LightningElement {

    @wire(getSiteExaminers) examiners;
}

and the error I am getting is: This page has an error. You might just need to refresh it. afterRender threw an error in 'c:siteExaminers_v2' [Cannot read property 'Name' of undefined] Failing descriptor: {c:siteExaminers}
Team  CodEngine.inTeam CodEngine.in
I think you need to map the apex response to the variable, 

for your reference 
 @wire(GetContactList, {})
    ApexResponse({ errordata }) {
        if (data) {
            this.data = data;
        } else if (error) {
            //test
        }
    }

check this link for more details 
https://www.codengine.in/2019/08/salesforce-lightning-datatable-example-with-lwc-lightning-web-component.html

--
Naveen K N
AmarpreetAmarpreet
Hi Justin, 

Try below code:
 
<template if:true={examiners.data}>
<template for:each={examiners.data} for:item='examiner'>
    <tr key={examiner.Id}>
        <th>{examiner.Name}</th>
        <th>{examiner.Title}</th> 
        <th>{examiner.Account.Name</th>
    </tr>
</template>
<</template>