I have one LWC component, which displays the list of Contacts. But its not displaying any data in the component. from debug log I can see my apex controller is returning data, but not sure why it is not getting displayed. I have taken the code from the lwc-recipes HTML:
<template>
<lightning-card
title="Apex Wire Method">
<template if:true={contacts.data}>
<template for:each={contacts.data} for:item="contact">
<p key={contact.Id}>{contact.name}</p>
</template>
</template>
</lightning-card>
</template>
js:
import { LightningElement, wire } from 'lwc';
import getContactList from '@salesforce/apex/ContactController.getContactList';
export default class ApexWireMetodToSalesforce extends LightningElement {
@wire(getContactList) contacts;
}
Apex:
public with sharing class ContactController {
@AuraEnabled(cacheable=true)
public static List<Contact> getContactList() {
return [SELECT Id, Name, Title, Phone, Email FROM Contact LIMIT 100];
}
}