【问题标题】:Meteor Call returning 404 Method Not FoundMeteor Call 返回 404 Method Not Found
【发布时间】:2015-01-16 05:47:05
【问题描述】:
        Meteor.call('create_question', title, content, function(error, result) {
            console.log('create_question error ' + error);
            console.log('create_question result ' + result);

            if (error) {

            } else {
                console.log('Your question was submitted');
            }
        });

这是我对客户端的调用 Meteor 调用。

我已经在服务器中获得了这个。

Meteor.methods({
    create_question: function(question_title, question_content) {
// does stuff   
    },

});

但由于某种原因,我不断收到 Method is not found。有谁知道怎么了?我在服务器文件夹中有 Meteor.methods,在客户端文件夹中有调用。

【问题讨论】:

    标签: javascript meteor


    【解决方案1】:

    方法create_question应该在客户端和服务器上定义。

    您可以使用this.isSimulation 来确定该方法是在服务器上执行还是在客户端上执行(作为存根)。

    【讨论】:

    • 为什么会这样?我总是在server 目录中定义我的方法,从来没有遇到过类似的问题。
    • @HubertOG 确实,文档似乎同意:You don't have to define a stub for your method if you don't want to.。我记得必须定义一个存根,但我想我会更深入地探讨一下。
    • 是的,我已经将它与其他方法一起使用。我自己会更深入地研究它。可能是特定于方法的,我将不得不查看内容。
    【解决方案2】:

    可能是您的create_question 方法中调用的另一个方法未定义。

    这是我的问题,但错误消息仍然说 create_question 方法是未定义的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-06
      • 2016-03-16
      • 2019-05-12
      • 1970-01-01
      • 2021-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多