[Vuejs]-Javascript get data through methods

0👍

Found my mistake

<script>
Vue.component('comments',{
  template: '#comment-vue-template',
  data:() => {
    return {
        comments: []
        }
    },
  created: function() {
    this.getComments();
  },
  methods: {
    getComments() {
      this.$http.get('/comments').then(response => {
        this.comments = response.body
      });
      setTimeout(this.getComments,1000);
    }
  }
});
new Vue({
  el:'#app',
});
</script>

Leave a comment