Problem with return data of "Collection.Customer.find()" on "Meteor.method()"?


#1

I have the problem with

// Server
Meteor.methods({
   myMethod: function(){
      return Collection.customer.find();
   }
})

// Client
var data = ReactiveMethod.call('myMethod');

Can’t get the data. please help me.


#2

Try returning Collection.customer.find().fetch()


#3

Work fine, why I can’t use return Collection.find() directly.


#4

From the documention:

Calling methods on the server defines functions that can be called remotely by clients. They should return an EJSON-able value or throw an exception.

find() returns a cursor, which is not an EJSON-able value, whereas fetch() returns an array, which is.


#5

What is ReactiveMethod?

EDIT: reactive-method package