[Vuejs]-My Vue object is not reactive. It works locally but not on hosted server

0👍

Have you call that getData method? It doesn’t call automatically by Vue. You can use mounted or created lifecycle hooks to call that method. Somekind like this,

 methods: {
  getData: function(){
   axios.get('/my/url')
   .then((response)=>{
     this.myObj = response.data;
     console.log("Response data: " , response.data); //**A**
     console.log("'This data:' " , this.data.purchaseorder); //**B**
   })
   .catch((error)=>{
    //ERROR
   });
  }
 },
 mounted () {
   this.getData()
 }

0👍

Change the getData method to the following, without function:

methods: {
  getData () {
    axios.get('/my/url')
     .then(response => {
       this.myObj = response.data;
       console.log("Response data: " , response.data); //**A**
       console.log("'This data:' " , this.data.purchaseorder); //**B**
     })
     .catch(error => {
       //ERROR
     });
  }
}

In this case, the context of this is bound within getData: function () { ... }

Leave a comment