Returning HTTP data client side

Hi all,

I’m new to Meteor and have been trying to return data synchronously to the client side to display on the page. On the server side:

http://puu.sh/p0Bzt/a79e9f0bad.png

and on the client I can’t figure out how to return the synchronous data because Meteor.call takes a callback function, which makes it async all over again. Any help is greatly appreciated!

Template.hello.helpers({ ``data() { return Meteor.call("getData", function(error, result){ if(error){ console.log("error", error); } if(result){ return result.data } }); }, });

Don’t know how to format ^^ sorry

Basically, a HTTP request is a fundamentally asynchronous operation. You can’t get away from that.
You need to wait for the result to arrive, because it takes a long time. And during that time some other part of your app will continue to execute.

Callbacks are a form of waiting, and then performing some limited task with the result.

If you want a larger part of your app to wait, you can (in Meteor 1.3) use an async function() that await the result of a Promised HTTP. That way your whole function will wait. But the function that called your async function() will continue.

And you can continue that up the calling stack, but at some point, your computer needs something to do while it is waiting for the result… :grin: