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 plete, 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);
});
}
});
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 plete, 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);
});
}
});
Share
edited Jan 18, 2015 at 23:51
austin
5,8762 gold badges34 silver badges40 bronze badges
asked Nov 14, 2014 at 8:50
zevsuldzevsuld
2764 silver badges15 bronze badges
2
- 1 What does the method look like? – user3374348 Commented Nov 14, 2014 at 9:11
- What error does it give and what does the method look like? – Marco de Jongh Commented Nov 14, 2014 at 11:07
2 Answers
Reset to default 5Just 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){
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})