gpt4 book ai didi

javascript - 调用方法时出错 'addNewDriveToSadranTable' : Internal server error [500]

转载 作者:太空宇宙 更新时间:2023-11-04 16:08:10 26 4
gpt4 key购买 nike

我对 Meteor.Call 和方法有疑问。

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

可能是什么错误?

client/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');
} });

collection/collections.js

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

最佳答案

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

感谢@masterAM的评论和回答

现在看起来像这样:

client/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');
}});

关于javascript - 调用方法时出错 'addNewDriveToSadranTable' : Internal server error [500],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41712317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com