33

I am assigning methods to a Meteor server like so:

In bootstrap.js

Meteor.startup(function () {
    Meteor.methods({

        foo: function () {
            return 1;
        },

        bar: function () {

        // QUESTION: HOW TO CALL Meteor.methods.foo
        return 1 + foo;        

        }
    });
});
1
  • 11
    By the way, there's no need to wrap Meteor.methods inside Meteor.startup.
    – debergalis
    Apr 28, 2012 at 21:50

1 Answer 1

59

The same way you would call bar: Meteor.call("foo");

If you are on the server and do not specify a callback the method will run synchronously.

Docs for Meteor.call: http://docs.meteor.com/#meteor_call

2
  • 3
    Ah yes, seems quite simple now, doesn't it? Thanks! Apr 27, 2012 at 2:28
  • How does it work when i have parameters: foo(param1, param2) and want return values (at least error)?
    – Gobliins
    Jan 10, 2018 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.