user592419
user592419

Reputation: 5223

Meteor API call to Server

I have a router.js set up that's accessible to both server and client. I then have a methods.js set up that's only on the server. I am trying to have the api call use the server's method, but router.js is not seeing the method at all: TypeError: Object #<Object> has no method 'handleLoginAPI'. How do I set this up correctly?

router.js

this.route('api-login', {
    where:'server',
    action: function() {
        var request = this.request;
        doSomething = function() {//send response}            
        Methods.handleLoginAPI(request, doSomething); 
    }
});

methods.js

Meteor.methods({
    handleLoginAPI: function(request, callback) {
        //check for valid user from request
        //login user
        //callback()
    }
});

Upvotes: 0

Views: 114

Answers (1)

Peppe L-G
Peppe L-G

Reputation: 8345

You should use Meteor.call to call a method (or what is your Methods-object?).

Upvotes: 1

Related Questions