调用Method' addNewDriveToSadranTable':内部服务器错误[500]时出错

时间:2017-01-18 05:55:11

标签: javascript meteor

我的Meteor.Call和方法存在问题。

我将console.log('test')放在方法代码中。控制台显示它,我可以在集合中看到一个毫秒的新文档(然后它就消失了)。

可能是什么错误?

的客户机/ sidurEditor.js

Template.sidurEditor.helpers({
    showForSadran: function() {
        return ForSadranDrives.find({},{sort: {askedDate: 1, since: 1}});
    }

LIB / methods.js

Meteor.methods ({
addNewDriveToSadranTable: function (askedDate, since, until, askedDrive, askedUser) {
    console.log('click');
    ForSadranDrives.insert({
        askedDate: askedDate,
        since: since,
        until: until,
        askedDrive: askedDrive,
        driveCar: "chooseCar",
        driveCarName: "car undefined",
        driveDriver: "driver undefined",
        askedUser: askedUser,
        askedNickName: Session.get('nickName'),
        onEditDriveRow: false
    });
    console.log('click2');
} });

收集/ collections.js

ForSadranDrives = new Mongo.Collection('forsadrandrives');

2 个答案:

答案 0 :(得分:1)

错误是我在方法中写了一个Session ...我把它放在Meteor.call(...)作为参数,它运行得很好!!

感谢@masterAM的评论和答案

现在看起来像那样:

<强>的客户机/ navbar.js

            Meteor.call('addNewDriveToSadranTable',askedDate, since, until, askedDrive, askedUser, Session.get('nickName'));

<强> LIB / methods.js

Meteor.methods ({
addNewDriveToSadranTable: function (askedDate, since, until, askedDrive, askedUser, askedNickName) {
    console.log('click1');
    ForSadranDrives.insert({
        askedDate: askedDate,
        since: since,
        until: until,
        askedDrive: askedDrive,
        driveCar: "chooseCar",
        driveCarName: "אין רכב מוגדר",
        driveDriver: "אין נהג מוגדר",
        askedUser: askedUser,
        askedNickName: askedNickName,
        onEditDriveRow: false
    });
    console.log('click2');
}});

答案 1 :(得分:0)

您看到的是Meteor的延迟补偿 - 记录被插入到本地数据库(minimongo)中,但在从服务器刷新数据库时消失。这很可能是因为您对数据的订阅丢失或者您的过滤器正在排除数据。

您可以使用命令

在mongo shell中查找记录进行检查
meteor mongo

确保您的CD位于项目目录