I am getting this error. I am trying to filter my array with my searchbar (input) I am doing search operation as computed.
<div class="post"
@click="getData(post.header,post.text)"
v-for="(post) in searchList"
v-bind:item="post"
v-bind:key="post._id"
>
Computed Property
computed:{
searchList() {
return this.posts.filter(post => {
return post.text.toLowerCase().includes(this.lookfor.toLowerCase())
})
}
},
Please help me, Thanks
posts,post.textis not a string. How about adding some simple debugging like this in yourfiltercallback ~console.log(typeof post.text, post.text)return post.text && post.text.toLowerCase().includes(this.lookfor.toLowerCase())post.textwasnullorundefined, the error message would be different. That being said, perhapspost.textis Booleanfalsefor some recordsStringhave a method.toLowerCase()