I am pulling values form apex method to display in the lightning combo box. I get 500 internal server error from the console log and i see the method name and class name are correct. Not sure where i am missing.
import { LightningElement, wire, track } from 'lwc';
import getDivisions from '@salesforce/apex/TrafficReportController.getDivisions';
export default class TrafficHistoryReport extends LightningElement {
@track divisionvalue = '';
@track Divisionvalues = [];
@wire(getDivisions)
ListDivisions({data,error}){
if(data){
for(let i=0;i < data.length;i++){
this.Divisionvalues.push({
label: data[i],
value: data[i]
});
}
//this.divisionoption = this.Divisionvalues;
}
else if (error){
window.consolde.log(error);
}
}
get divisionoption() {
//console.log(this.Divisionvalues);
return this.Divisionvalues;
}
handleChange(event){
event.preventDefault();
console.log('value'+event.target.value)
}
}
Apex:
public with sharing class TrafficReportController {
public TrafficReportController() {
}
@AuraEnabled (cacheable=true)
public static List<String> getDivisions(){
List<Division__c> LstDivisions = [Select id, Name from Division__c];
List<String> Lststrings = new Lststrings();
for(Division__c Div:LstDivisions){
Lststrings.add(Div.Name);
}
return Lststrings;
}
}
HTML:
<template>
<div>Traffic History Report</div>
<div>
<lightning-combobox name="Divisions" label="Divisions" placeholder="Select a Division" value={divisionvalue} options={divisionoption} onchange={handlechange}></lightning-combobox>
</div>
</template>