After making an API call, I receive JSON-formatted data with a specific structure like this:
data = [ { name: 'John',
school:[ { school_name: 'Harvard', date_attended: '2017-05-23' },
{ school_name: 'UCLA', date_attended: '2012-03-13' } ]
},
{ name: 'Harry',
school:[ { school_name: 'Stanford', date_attended: '2015-09-18' }]
},
....
]
Within the context of my project, I have a computed property referred to as filterSearch
computed: {
filterSearch() {
if(this.search == '') {
return this.teachers_list;
} else {
return this.teachers_list.filter( hero => {
return hero.name != null
?
!this.search || hero.name.toLowerCase().includes(this.search.toLowerCase())
: ''
})
}
}
}
The current implementation works perfectly when searching for names. However, I am now looking for a way to modify it such that it can also effectively search based on the school name field.