Q:

how to execute a server script and then pass the information to the client in meteor

I'm working with two files [root]/test.js with a calling function
Meteor.call("getUsers", "Juan P", function (error, result) {
           console.log(result);
      });

and another file [root]/server/secret.js with this definition
if (Meteor.isServer) {
      var getUsers = function(name) {
           return "Hi. I'm " + name;
      };
}

however the function getUsers is getting undefined, I really appreciate any help or hint about fixing this problem! :-)

A:

You have to define it as a Meteor.method
Meteor.methods({
    getUsers: function (name) {
       return "Hi. I'm " + name;
    }
});

Also, when you put your code in /server/ folder you don't have to check Meteor.isServer anymore, it makes it a little cleaner. Same goes for /client/ and Meteor.isClient.

