I'm currently stuck trying to implement pagination in my task and it's not functioning as expected.
My approach involved creating two buttons with click events attached, along with a data property that changes when the buttons are clicked. This property is then written into the link, consequently updating the display to show the next set of 10 posts.
Despite this setup, something seems to be off and the functionality isn't working as intended. I would greatly appreciate any insights on where I might be going wrong, as well as recommendations for articles related to pagination.
Here is a snippet of my HTML:
<button type="button" @click="counter -=1" class="prev">Prev</button>
<div class="counter">{{ counter }}</div>
<button type="button" @click="counter +=1" class="next">Next</button>
This is an excerpt from the Vue component:
export default {
name: 'app',
data () {
return {
counter: 1,
zero: 0,
posts: [],
createTitle: '',
createBody: '',
visiblePostID: ''
};
},
created () {
axios.get('http://jsonplaceholder.typicode.com/posts?_start=${this.counter}+${this.zero}&_limit=10').then(response => {
this.posts = response.data;
});
}
};