Vue-resource
is a resource plugin for Vue.js.
This plugin provides services for making web requests and handles responses using XMLHttpRequest
or JSONP.
We are going to make again all the web requests we made above, using this plugin instead. This way you can see the differences and decide which one is better for your needs. jQuery is nice, but if you are using it only to perform AJAX calls, you may consider removing it.
Here you can find installation instructions and documentation about vue-resource
(https://github.com/vuejs/vue-resource). As usual, we are going to "pull it in" from the cdnjs (https://cdnjs.com/libraries/vue-resource) page.
To fetch data from a server and bring them up to display in the browser, we can use the vue-resource
plugin's $http
method with the following syntax:
ready: function() { // GET request this.$http({url: '/someUrl', method: 'GET'}) .then(function (response) { // success callback }, function (response...