2👍
axios.post('https://test.com/api/getMessage',{}).then(res => {
this.message = res.data.message
})
That should work – Arrow functions take place in the scope in which they are written, meaning this
will refer to your Vue instance there. If you were not using arrow functions, you would have to specifically bind the scope:
axios.post('https://test.com/api/getMessage',{}).then(function(res){
this.message = res.data.message
}.bind(this))
👤Jeff
Source:stackexchange.com