vue-resource $http not Work

521 Views Asked by At

I'm trying to use vue with vue-resource without success. what am I doing wrong? Follow the code

I'm using CDN

I'm starting with the vuejs and I appreciate the help.

<div id="beerApp">
<ul>
 <li v-for="cervejaria in cervejarias">{{cervejaria.name}}</li>
</ul>
</div>



<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.3/vue-resource.min.js"></script>

<script>

// vue js codes will be here
new Vue({
  el:'#beerApp',

data:{
    cervejarias: []
 },

ready:function ()
{
  this.$http.get('https://gist.githubusercontent.com/vedovelli/3a83755e576778088c93/raw/204ced0602760829597f5caa2680e5f7cb29bade/cervejarias.json').then((response) => {
    this.$set('cervejarias',response.json()) 
  }, (error) => {
     consoel.log(error)
  });

}

});

1

There are 1 best solutions below

0
On

It's because there are no longer ready() lifecycle hook into Vue 2.

Instead you can go with mounted() or created() lifecycle hooks.