Trying to implement pagination for fetched data in a Vue project, but encountering an issue:
New Question
Error encountered during rendering: "TypeError: this.estates.filter is not a function"
Am I overlooking something here?
Pagination.vue
Data(){
return {
meta_data: {
last_page: null,
current_page: 1,
prev_page_url: null
}
}
},
mounted() {
this.fetchEstates();
},
methods: {
fetchEstates(page = 1) {
axios.get('/ajax', {
params: {
page
}}).then((response) => {
this.estates = response.data;
this.meta_data.last_page = response.data.last_page;
this.meta_data.current_page = response.data.current_page;
this.meta_data.prev_page_url = response.data.prev_page_url;
});
}
},
computed: {
one: function () {
let filteredStates = this.estates.filter((estate) => {
return (this.keyword.length === 0 || estate.includes(this.keyword)) &&
(this.rooms.length === 0 || this.rooms.includes(estate.rooms)) &&
(this.regions.length === 0 || this.regions.includes(estate.region))});
/// rest of the code....
If you require more details, please let me know.