Reputation: 2128
I am trying to make an e-commerce app which lets users buy items after adding them to a cart. However, I have been trying to pass data from the client to the server (e.g. total cost of the items in cart, list of the items in the cart) so that the server can handle the billing, and I cant seem to find a way to do so. What would be the best practice for handling such a situation?
Upvotes: 0
Views: 691
Reputation: 268
Here is a little code sample I use to get form data passed to a meteor method.
'submit #payment-form': function (event, instance) {
event.preventDefault();
var formData = {};
instance.findAll('input').forEach(function (input) {
formData[input.id] = input.value;
});
Meteor.call('someMethod', formData, function(error, result){
if(error){
console.log(error);
}
});
}
Upvotes: 1
Reputation: 436
One of the way you can pass data into server use Meteor.methods
and call it on the client. for more information you can see meteor documentation
for example you defined a method
on the server and call it on the client.
Upvotes: 1