I'm trying to send a post request via vue-resource and I can't quite seem to figure out what I'm doing incorrectly.
I'm using Laravel 5.1 to process the request.
The following jquery code works fine from within my Vue method.
$.ajax({
type: 'POST',
url: '/purchase/save-cart-items',
data: { 'purchaseItems' : purchaseItems},
success: function (response) {
if(response == "ok") {
alert("Cart saved successfully.");
} else {
alert('There was a problem saving this cart. Please try again.');
}
}
});
However, the replacing the jquery above with the following vue-resource post request doesn't work for some reason. I'm sure it's something simple, but I can't seem to figure it out. Vue-resource is properly included in the project as I'm using it for get requests without issue.
this.$http.post('/purchase/save-cart-items', {purchaseItems:purchaseItems}, function (data, status, request) {
alert("Cart saved successfully.");
}).error(function (data, status, request) {
alert('There was a problem saving this cart. Please try again.');
});