I have tried this code but couldn't find the error can you anyone help me out what issue in the code
Lightning DataTable.html file
<template>
<lightning-card title="Lightning DataTable">
<template if:true={oppList}>
<lightning-datatable data={oppList} columns={column} key-field="Id">
</lightning-datatable>
</template>
<template if:true={error}>
{error}
</template>
</lightning-card>
</template>
Lightning DataTable.js file
import { LightningElement ,api,track,wire} from 'lwc';
import getOpportunities from '@salesforce/apex/GetOpportunities.getOpportunities';
export default class LightningDataTable1 extends LightningElement {
@track column = [{label: 'Name', fieldName: 'Name'},
{label: 'Amount', fieldName: 'Amount'},
{label: 'Stage', fieldName: 'StageName'}];
@track error;
@track oppList ;
@wire(getOpportunities)
wiredOpportunities({error,data}) {
if (data) {
this.oppList = data;
} else if (error) {
alert('error');
this.error = error;
}
}
}
Apex Class
public with sharing class GetOpportunities {
@AuraEnabled
public static List<Opportunity> getOpportunities() {
try {
List<Opportunity> getopportunity = [Select Name,Amount,StageName from Opportunity Limit 5];
return getopportunity;
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}
I have attached the error message I am getting in org
Let me know in the comment section guys