raviawasti
2 months ago

How to load after liking post in vuejs(laravel) without refreshing page using infinite scroll? help me fix this issue laravel or vuejs developer please

Posted 2 months ago by raviawasti

i am able to see all the data after posting data, liking post , commenting on post without page refresh but after using infinite scroll in vuejs, infinite scroll working perfectly fine but not able to see post after liking ,commenting , posting..i have to refresh every time to see the comment/like on post. How can i see ontime like without page refresh ?Please help me figure this out anyone


    el: '#app',

data() {

  return {

  posts: [ ],

  page: 1,
  
    };
  },

 created(){

this.allposts();

    },
}
 methods:{

Before using infinite scroll on app.js


 allposts(){

               axios.get('http://localhost/project/posts')

                .then((response) => {
                    this.posts = response.data;
                    Vue.filter('myOwnTime', function(value){
                    return moment(value).fromNow();
          });
                })
                .catch(() => {
                    console.log('handle server error from here');
                });
    },

After using  vue infinite scroll

https://peachscript.github.io/vue-infinite-loading/guide/start-with-hn.html

 allpost($state) {

      axios.get('http://localhost/project/posts', {

        params: {

          page: this.page,


        },
      })
      .then(({ data }) => {
        if (data.data.length) {
          this.page += 1;
          this.posts.push(...data);
            Vue.filter('myOwnTime', function(value){
                    return moment(value).fromNow();
          });
          $state.loaded();
        } else {
          $state.complete();
        }
      });
    },


like function is same for both 

       likePost(id){
     axios.get('http://localhost/project/posts' + id)     

          .then(response => {
            console.log(response); 
                    this.allposts();//
          })
          .catch(function (error) {
            console.log(error);
          });
   },


} ```

How can i see ontime like without page refresh ?Please help me figure this out

Please sign in or create an account to participate in this conversation.