Search code examples
javascriptmeteor

Meteor reports my server method does not exist


fairly new to Meteor and JS, doing a lot of reading and research. I have been following an example of an HTTP request but I keep getting an error "404, method Abc not found":

This is how my JS file looks like:

if (Meteor.isServer) {
    Meteor.methods({
        Abc: function () {
            this.unblock();
            return Meteor.http.call("GET", //HTTP REQUEST TEXT);
        }
    });
}

if (Meteor.isClient) {
    Meteor.call("Abc", function(error, results) {
        console.log(error);
        console.log(results); 
    });
}

Why the server method is not found if it is in the same file? I only want to show the content of the HTTP response.

Debugging and re-reading the tutorials.


Solution

  • Apparently, your code is loaded only on the client side. You should separate the client and the server logic by using the "client" and "server" folders respectively . Or in your example you should use "both" folder.