[Vuejs]-How to access data from Method in Computed

0👍

You call this.req.results in computed while the initial data is req: {} and asynchronous fetchData() method does not resolve instantly, that’s why it causes an error. Do something like:

computed: {
  filteredRequests () {
    if (this.req.results) {
      return this.req.results.filter(item => {
        return item.created.toLowerCase().includes(this.name)
      })
    } else {
      return 'No results'
    }
  }
}
👤Igor

Leave a comment