[Vuejs]-Axios typeError: Cannot set property 'username' of undefined

0👍

you should use the arrow function in es6 instead of function () in here,

example: (response)=>{ instead of function(response){

methods: {
      getInfo () {
          axios.get('http://localhost:8088/api/information')
          .then((response)=> {
              this.username = response.data['username'];
              this.email = response.data['email'];
              console.log(response);
        })
        .catch(function (error) {
              console.log(error);
        });
    }
}

Leave a comment