I'm making an API call and getting (an expected) error back. I can console log the error message but I can not seem to set a vuejs data variable with the response. What am I doing wrong?
data: {
...
...
errors: null
},
methods: {
checkConnections: function (event) {
axios.post('/checkconnections', {
//form data is passed here
...
...
})
.then(function (response) {
console.log(response);
}).catch(function (error) {
console.log(error.response.data.error);
this.errors = error.response.data.error;
});
}
}
The console.log(error.response.data.error)
part works fine but the assignment this.errors = error.response.data.error;
is not. Any ideas?