Answer the question
In order to leave comments, you need to log in
How to make Ajax requests in vue.js?
I'm trying to figure out how to bind Ajax to vue. The search does not help, the documentation of the framework is very good, but for some reason it also bypasses the question of how to actually deliver data to the vue application.
I write like this:
new Vue({
delimiters: ['{*', '*}'],
el: '#app',
data: {
message: 'Hello Vue.js!',
values: []
},
created: function() {
this.$http.get('/inspector/vue').then(
function (response) { // Success.
console.log(response.data);
this.values = response.data;
},
function (response) { // Error.
console.log('An error occurred.');
}
);
}
})
Answer the question
In order to leave comments, you need to log in
How is it customary to make such requests in vue?
Try using axios :)
axios.get('/url').then((response) => this.data = response.data.response)
.catch((error) => console.log(error.response.data));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question