I'm trying to understand Vue
and it's dependencies (newbie) just need help to understand the way axios works so it can be clear to me.
If I use code below it works to returning my data:
methods: {
load: function() {
axios.get('/api/projects')
.then(
response => {
this.projects = (response.data.projects);
}
)
.catch(function (error) {
this.errors.push(error);
console.log(error);
})
}
}
But if I use code below it doesn't return data:
methods: {
load: function() {
axios.get('/api/projects')
.then(function (response) {
this.projects = (response.data.projects);
})
.catch(function (error) {
this.errors.push(error);
console.log(error);
})
}
}
The difference is in .then
part only.