[Vuejs]-VueJs2 HTTP Get Request from JSON API

0๐Ÿ‘

โœ…

i dont see any issues in your code

maybe you are not including vue-resource (required to use this.$http)

new Vue({
  el: '#app',
  data() {
    return {
      blogs: []
    }
  },
  methods: {

  },
  created() {
    this.$http.get('https://jsonplaceholder.typicode.com/posts').then(function(data) {
      //console.log(data);
      this.blogs = data.body.slice(0, 10);
    })
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
<div id="app">
  <ul>
    <li v-for="blog in blogs">
      {{ blog.id }} - {{ blog.title }}
    </li>
  </ul>
</div>
๐Ÿ‘คJa9ad335h

Leave a comment