Hi I am new to Vue world and here is the warning I get: The success method has been deprecated. Use the then method instead.
And here is the code:
apiURL = 'api/movies';
new Vue({
el: '#app',
data: {
'movies': ''
},
ready: function() {
this.getMovies();
},
methods: {
getMovies: function() {
this.$http.get(apiURL, function(movies) {
this.$set('movies', movies);
});
}
}
});
Also is this a right method to do this kind of stuff?
You can do:
this.$http.get('/').then(function (response) {
this.$set('movies', response.data);
}
All in all, vue-resource
is somewhat buggy and unpolished. If you use the latest version, the only explanation would be that developer used his own deprecated method. Namely, success
instead of then
.
Your GET request should be using the then
promise like so:
this.$http.get(apiURL).then(function (movies) {
this.$set('movies', movies);
});
Just as shown in the vue-resource read-me page: https://github.com/vuejs/vue-resource#example
The deprecation warning is coming from this line: https://github.com/vuejs/vue-resource/blob/ed85a38a1c88faf4e1ac1d7c15cca8376aa933c8/dist/vue-resource.js#L853
To answer your last question, there is nothing inherently wrong with your methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With