Reputation: 1007
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! :-)
Upvotes: 0
Views: 67
Reputation: 364
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.
Upvotes: 3