March 03, 2015

Meteor Async from server to client

Sometime you want to do async call from api and make call or reactive on the client side, so how do you do it?
first create a method on server side, I would always recommend using methods rather allow / denied from client side, lets give a method name asyncMethods



Ok now run this client side method call

you will notice 2 things, on your console.log for client will become undefined, and on server side log you properly see some results.
so lets say you want to return result after api was called, meteor provided a very helpful method call Meteor.wrapAsync(), which basically returns your async call to synchronous call, so you could call it from client side, change your server code to this: