Created
January 31, 2018 08:43
-
-
Save mitrallex/af88d51cb02d2ed5b60020425113b38b to your computer and use it in GitHub Desktop.
pagination-app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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