mstorkson mstorkson -4 years ago 124
Javascript Question

Meteor callbacks returning undefined

So I've recently started using Meteor.js, and although I appreciate its power, I'm having some issues with the way some of it works. I have a very basic couple of functions that I'm trying to use to get the hang of returning data to the client.

In my server folder:

"thing": (number) => {
return number;

And then when it is used:

const five ="thing", 5);

But all I get is

This is so basic, I assume I must have a fundamental misunderstanding about how this process is supposed to work. I have tried reading up on similar questions, but they mostly reference asynchronous processes, whereas this shouldn't wait on anything.

Answer Source

any communication from client to server is asynchronous, including Meteor methods. you're using a synch return value, which isn't what you're expecting.

make it more like this:'thing', function(error, result) {
        if (error) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download