Meteor Server Function Return Value to Client

I’m building a simple Login page and I want to understand how server side functions can notify the client when are done.

On my application, when I click a button I get the values password and user and call a server side function. My problem is that I need to tell the client if those credentials were valid or not. To do that my server side function POST an address and returns a value, because this is happening asynchronously, I’m not been able to return if the credentials were valid to the client.

By the way, I already checked http://www.meteorpedia.com/read/Async_on_server, and it seemed to me the worst possible solution, just delay the callback for some time? I can enumerate a few reasons why this would be a bad idea.

Anyway, I’m still on the basics and I’m having a hard time to understand how to handle this problem. All help is welcome.

Best Regards,

Ernani

The “Meteor” way would be to use a Meteor Method, which lets the client call a function that’s defined on the server and get it’s response back. The standard web way (not Meteor-specific) would be to just use the simple:rest package to create a server-side route and make a request to that route from the client via the Meteor HTTP package.

Thanks for the reply @efrancis, I end it up creating a REST API and using Meteor.wrapAsync to sync it.

Best Regards, Ernani

Give this a read: http://www.meteor-tuts.com/chapters/1/users.html Some tutorials I made, still in draft, but may give you a very good idea.