juanp_1982
juanp_1982

Reputation: 1007

using Meteor.call with objects as argument

my problem is that Meteor.call send empty array to Meteor.method when I try to send kind of "complex"objects. this is what I mean:

// this works, I can see this array from Meteor.method
var data = ["cpu", "vmem", "mem", "JG_slots"];
Meteor.call("getDimentionValue", data.dimention, function (error, result) { ... });

// this DOESN'T work, I see an empty array from Meteor.method
var data = [{JB_owner: []}, {dimention: []}, {job_state:[]}];
Meteor.call("getDimentionValue", data.dimention, function (error, result) { ... });

I have tried EJSON.stringify(data) but nothing, any suggestion???

thanks!

Upvotes: 1

Views: 7004

Answers (1)

255kb - Mockoon
255kb - Mockoon

Reputation: 6984

I think that you should be using Meteor.apply() in order to call a method with an array of arguments, see the documentation for Meteor.call():

http://docs.meteor.com/#/full/meteor_call

See also Meteor.apply, which is identical to Meteor.call except that you specify the parameters as an array instead of as separate arguments and you can specify a few options controlling how the method is executed.

Upvotes: 4

Related Questions