O'Reilly logo

The Majesty of Vue.js by Kostas Maniatis, Alex Kyriakidis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Pagination links

By now, we have our pagination object but we always fetch the first page of stories since we are making a GET HTTP request to api/stories. We have to change the requested page based on user input (next page, previous page).

First we'll update the fetchStories method to accept an argument with the desired page. If no argument is passed, it will fetch the first page. I'll also create a new method makePagination to make the code cleaner:

new Vue({     ...     methods: {        ...        fetchStories: function (page_url) {           var vm = this;           page_url = page_url || '/api/stories'           this.$http.get(page_url)              .then(function (response) {                 var storiesReady = response.data.data.map (function ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required