简体   繁体   中英

METEOR: Error invoking Method

I have the following error:

the function "saveCalEvent" is not found on the server

but I did write it.

Why do I get:

Error invoking Method 'saveCalEvent': Method not found [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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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