调用方法时Meteor应用程序崩溃

时间:2015-07-29 16:28:31

标签: javascript meteor

我有一个集合,我使用以下代码插入了多个文档:

Meteor.methods({
  addProject: function (source, title, artist, description, price) {
    // Make sure the user is logged in before inserting a task
    if (! Meteor.userId()) {
      throw new Meteor.Error("not-authorized");
    }

    Projects.insert({
      source: source,
      title: title,
      artist: artist,
      description: description,
      price: price
    });
  }
});

我创建了以下方法:

Meteor.call("addProject", "http://mybuzzblog.com/wp-content/uploads/2014/12/German-Shepherds.jpg", "Dog 3", "Me", "happy dog", "$60");

当我尝试调用该方法时,应用程序崩溃并引用以下代码行:

W20150729-12:26:31.609(-4)? (STDERR)
W20150729-12:26:31.610(-4)? (STDERR) C:\Users\Raj\AppData\Local\.meteor\packages
\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fiber
s\future.js:245
W20150729-12:26:31.610(-4)? (STDERR)
throw(ex);
W20150729-12:26:31.610(-4)? (STDERR)
      ^
W20150729-12:26:31.610(-4)? (STDERR) Error: Method not found [404]
W20150729-12:26:31.610(-4)? (STDERR)     at [object Object]._.extend.apply (pack
ages/ddp/livedata_server.js:1502:1)
W20150729-12:26:31.613(-4)? (STDERR)     at [object Object]._.extend.call (packa
ges/ddp/livedata_server.js:1472:1)
W20150729-12:26:31.613(-4)? (STDERR)     at app\art.js:5:8
W20150729-12:26:31.613(-4)? (STDERR)     at app\art.js:137:3
W20150729-12:26:31.613(-4)? (STDERR)     at C:\Users\Raj\art\.meteor\local\build
\programs\server\boot.js:222:10
W20150729-12:26:31.614(-4)? (STDERR)     at Array.forEach (native)
W20150729-12:26:31.614(-4)? (STDERR)     at Function._.each._.forEach (C:\Users\
Raj\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bu
ndle\server-lib\node_modules\underscore\underscore.js:79:11)
W20150729-12:26:31.614(-4)? (STDERR)     at C:\Users\Raj\art\.meteor\local\build
\programs\server\boot.js:117:5
=> Exited with code: 8
=> Your application is crashing. Waiting for file change.

以下是控制台显示的内容。

"<Reason/>"

我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

确保您的Meteor.methods位于服务器文件夹下或Meteor.isServer条件下。