Josh Petitt
Josh Petitt

Reputation: 9579

Meteor how to call a method defined in Meteor.methods()?

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;        

        }
    });
});

Upvotes: 33

Views: 29944

Answers (1)

greggreg
greggreg

Reputation: 12085

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

Upvotes: 59

Related Questions