简体   繁体   English

流星:错误调用方法

[英]METEOR: Error invoking Method

I have the following error: 我有以下错误:

the function "saveCalEvent" is not found on the server 在服务器上找不到函数“ saveCalEvent”

but I did write it. 但我确实写过

Why do I get: 为什么会得到:

Error invoking Method 'saveCalEvent': Method not found [404] 调用方法'saveCalEvent'时出错:未找到方法[404]

even if I did write the method server-side? 即使我确实在服务器端编写了方法?

Here is my code: 这是我的代码:

CalEvent = new Mongo.Collection('callevent');
if (Meteor.isClient) {
  Template.main.rendered = function(){
    var calendar = $('#calendar').fullCalendar({
      dayClick: function(date, allDay, jsEvent, view){
        var calendarEvent = {};
        calendarEvent.start = date;
        calendarEvent.end = date;
        calendarEvent.titel = 'New Event';
        calendarEvent.owner = Meteor.userId;
        Meteor.call('saveCalEvent', calendarEvent);
      }
    })
  }
}

if (Meteor.isServer) {
  Meteor.startup(function () {
    Meteor.methods({
      'saveCalEvent' : function(ce){
         CalEvent.insert(ce);
      }
    });
  });
}

Meteor handles some directories differently. 流星处理某些目录的方式有所不同。 A list of special folders and their scope is listed here . 特殊文件夹及其范围的列表在此处列出。

Server code stored within the client folder will not be visible to the server and is therefore dead code. 客户端文件夹中存储的服务器代码对服务器不可见,因此为无效代码。

Special directories are: 特殊目录是:

  • client 客户
  • client/compatibility 客户/兼容性
  • server 服务器
  • public 上市
  • private 私人的
  • tests 测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM