Take the 2-minute tour ×

I am new to meteor and running to an issue trying to call a server method on the client.

// Client code 
 'click #test-button' : function(e, t) {      
    Meteor.call('testMethod', function(err, response){
      if (err) {
        alert("error: "+ err)
      } else{

// server code
if (Meteor.isServer) {

    testMethod: function () {
       return "success";

When I click on the button, I got a Error: Method Not Found 404. I tried to put the server method inside Meteor.startup and still gets the same error.What am I missing?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It looks like your code is only running on the client side. Move the block inside the if (Meteor.isServer) to a javascript file in the /server directory of your project.

Code inside the /client directory wont run on the server at all, so Meteor.isServer would always be false and the method would never get created on neither the client or server

share|improve this answer
Sorry for the late reply. It works when I move the code to the server folder. However, what is the point of the Meteor.isServer then? –  Yang Zeng Aug 8 '13 at 1:36
Its for distinguishing where you run your code if you put it in the root directory (runs on both the server and client). Sometimes you might want to share the same code but have little tweaks between the server and client. But its not too advisable as the copy of the server side code would be sent to the client, but it wouldn't run. –  Akshat Aug 8 '13 at 9:30
add comment

Your Answer


