Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

TypeError: Cannot read property 'indexOf' of undefined

$
0
0

@Shola wrote:

I am trying to create a search in ionic 5 and i keep getting this error. i discovered that the filter is not returning an array but JSON, i don’t know why this is happening. i am fetching my data from firebase and push the content to an array, it is from this array i want to search for topics.
Please check my code and the picture reference of the data i have in my posts array

 searchTopics(event:any)
  {
    const searchQuery = event.target.value;
      console.log(this.posts)
    this.posts = this.posts.filter(ret => {
      if (ret.topic && searchQuery ) {
        if (ret.topic.toLowerCase.indexOf(searchQuery.toLowerCase()) > -1) {
          return true;
        }
        return false;
      }

    })
  }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>