Meteor method callback returns undefined


#1

Having some trouble here with returning a callback result to the meteor call.

I have a meteor method that I call and from inside this method I insert a new document within a collection.
I am able to log the callback result to my console with the id of the new document succesfully.

My problem is when I attempt to return this back to the call method, the result is undefined.

Do I need to use wrapAysnc method around the insertion?


#2

See:



#3

Client/server context is very important when talking about Meteor methods/asynchronous code.

On the client if you don’t have a stub (method also defined on client) then Meteor.call it will return undefined

Links:


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


#4

Nope, it will return undefined even if you have a stub.


#5

Oh, you’re right, I misread… it was late last night heh :blush: