[Vuejs]-VueJS Data from API call not displaying

0👍

It appears you aren’t binding to the context of the beforeCreate method in your axios promise functions.

By using the forward arrow function to bind the context of your component to the axios promise function you will be able to update the component data object properly:

beforeCreate : function(){
  axios.get('/')
    .then((response) => {
      this.results =  response.data
      console.log(this.results)
    })
    .catch((error) => {
      console.log(error)
    });
},

Leave a comment