[Vuejs]-How can i render data using axios.get

0👍

It looks like you should be doing this…

loadUsers(){
    axios.get('/Thirdparty/loadUsers').then((res) => {
       this.users = res.data.users;
    });
 }

You also don’t need to define a self var you can use this..

 created(){
  this.loadUsers(); 
 }

0👍

Did you try with computed property , something like this :

computed: {
   loadUsers(){
    axios.get('/Thirdparty/loadUsers').then((res) => {
       this.users = res.data.users;
    });
 }
}

Or if you want to get data , on component rendering maybe mounted is another option

And in ES6 you can use straight this …. maybe using inside the varibale self , it can occurs problem with the scope ?

created(){
     this.loadUsers(); 
  }

Leave a comment