in my controller , i return a collection as json object
you can change the name to event
export default {
mounted () {
this.getPosts ()
}
props : {
url: String,
},
data () {
return {
collection : {
data : []
},
query: {
limit: 10,
page: 1
},
}
},
methods : {
getPosts () {
const params = {
...this.query
}
axios.get(this.url , {params : params})
.then(
response => {
this.collection = response.data.collection
this.query.page = response.data.collection.current_page
}
)
.catch((error) => {
})
.finally(() => {
});
},
changePerpage () {
this.query.page = 1
this.getPosts ()
},
nextPage () {
if (this.collection.next_page_url) {
this.query.page = Number(this.query.page) + 1
this.getPosts ()
}
},
prevPage () {
if (this.collection.prev_page_url) {
this.query.page = Number(this.query.page) - 1
this.getPosts ()
}
},
}
}