Skip to content

Instantly share code, notes, and snippets.

@mitrallex
Created January 31, 2018 08:43
Show Gist options
  • Save mitrallex/af88d51cb02d2ed5b60020425113b38b to your computer and use it in GitHub Desktop.
Save mitrallex/af88d51cb02d2ed5b60020425113b38b to your computer and use it in GitHub Desktop.
pagination-app.js
window.Vue = require('vue');
Vue.component('pagination', require('./components/PaginationComponent.vue'));
const app = new Vue({
el: '#app',
data: {
posts: {},
pagination: {
'current_page': 1
}
},
methods: {
fetchPosts() {
axios.get('posts?page=' + this.pagination.current_page)
.then(response => {
this.posts = response.data.data.data;
this.pagination = response.data.pagination;
})
.catch(error => {
console.log(error.response.data);
});
}
},
mounted() {
this.fetchPosts();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment