Hey there, hoping you're having a good night! I've been trying to set up a bookstore using Vue.js with code retrieved from a Json api. However, I'm encountering some issues with the "computed" property. Here's the code snippet:
new Vue({
el: "#vue-app",
data() {
return {
title: "Ubiqum Bookstore",
books: []
}
},
mounted() {
this.getAPI('https://api.myjson.com/bins/1h3vb3');
},
methods: {
getAPI() {
axios.get('https://api.myjson.com/bins/1h3vb3')
.then(response => {
(this.books = response.data.books)
})
.catch(e => {
console.log("No found!")
})
}
},
computed: {
booksFilter: function() {
var textSearch = this.textSearch;
return this.books.filter(function(el) {
return el.books.toLowerCase().indexOf(textSearch.toLowerCase()) !== -1;
});
}
},
})
I'm puzzled about why the computed property isn't functioning as expected. In my HTML, I have:
<div id="list-countries" v-if="booksFilter && booksFilter.length">
<div class="panel panel-default" v-for="book of booksFilter">
<input id="input-search" type="text" class="form-control" v-model="search" placeholder='Search...'>
If you have any insights or solutions to this issue, I'd greatly appreciate it! Thank you very much!