I am using Meteor.call
method for invoking a function on server. It is kind of working, however it seems like result is not fully returning. (Expecting length of 250, now it returning 11, 121, something like that)
I am using async Meteor.call
. I am guessing before server side function complete, Meteor.call
is returning a result. I tried sync call but I'm not clearly understand the Meteor docs.
So I am trying to use Meteor.apply()
with options. How can I use Meteor.apply
with options? Any examples?
client.js
var chartData;
Template.prodSelect.events({
'click': function(e){
e.preventDefault();
var prodName = document.getElementById("productSelect").value;
//console.log(prodName);
Meteor.call('chartData', prodName,function(err,data){
if (err)
console.log(err);
chartData = JSON.parse(data);
//console.log(data);
createChart(chartData);
});
}
});
Tried this , but is gives error.
var chartData;
Template.prodSelect.events({
'click': function(e){
e.preventDefault();
var prodName = document.getElementById("productSelect").value;
//console.log(prodName);
Meteor.apply('chartData', prodName,{wait: true}, function(err,data){
if (err)
console.log(err);
chartData = JSON.parse(data);
//console.log(data);
createChart(chartData);
});
}
});
In order not to receive Malformed method invocation
error, you should pass arguments as an array.
And in addition to @robut's answer:
It's still best to see what options you are passing, thus I prefer:
Meteor.apply('addPost',[] ,{wait:true})
Just figured this out myself. You need to pass the arguments as an array, and to specify "wait", you just pass true
to the function. So, in your case:
Meteor.apply('chartData', [prodName], true, function(err, result){
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