I have a computed method that I am trying to execute:
get dronesFiltered(){
const filtered = this.drones.filter((drone) => {
return drone.id.toString().indexOf(this.filterId) > -1 && drone.name.toLowerCase().toString().indexOf(this.filterName.toLowerCase()) > -1 && drone.status.toLowerCase().toString().indexOf(this.selectedStatus.toLowerCase()) > -1 && this.statusFly(drone.fly, drone.status).indexOf(this.selectedCurrentFly) > -1;
});
return filtered;
}
The method runs successfully but displays the following errors:
Property 'status' does not exist on type 'never'
This error occurs for status, id, name, fly (every field I'm trying to filter). How can I resolve this issue?
Below is my component code snippet:
@Component({})
export default class List extends Vue {
drones = []
selectedStatus = ''
selectedCurrentFly = ''
filterId = ''
filterName = ''
mounted(){
this.listDrones(1);
}
get dronesFiltered(){
const filtered = this.drones.filter((drone) => {
return drone.id.toString().indexOf(this.filterId) > -1 && drone.name.toLowerCase().toString().indexOf(this.filterName.toLowerCase()) > -1 && drone.status.toLowerCase().toString().indexOf(this.selectedStatus.toLowerCase()) > -1 && this.statusFly(drone.fly, drone.status).indexOf(this.selectedCurrentFly) > -1 ;
});
return filtered;
}
public async listDrones(current: number) {
try {
const res = await dronesController.getDronesWithLimit(current);
const resTotal = await dronesController.getDrones();
this.totalRows = resTotal.data.length;
this.drones = res.data;
} catch (err) {
console.log(err);
}
}
}