Hey peeps, I’m trying to update some records from the client by doing a
Meteor.call('updateComment'...)
, but I keep getting a server error
on the client side.
Could someone please point me in the right direction?
Thanks in advance.
Full-Error
errorClass {error: 500, reason: "Internal server error", details: undefined, message: "Internal server error [500]", errorType: "Meteor.Error"}
editComment.js
// Events
Template.editComment.events({
'click .form-save': (e) => {
e.preventDefault();
let commentContent = $('.update-comment').val();
let fritkotId = Fritkots.findOne({})._id;
let commentId = Comments.findOne({})._id;
Meteor.call('updateComment', commentContent, commentId, fritkotId, function(error) {
if (!error) {
console.log('comment updated');
} else {
console.log(error);
console.log('unable to update comment');
}
})
console.log(`The comment was updated to this ${commentContent}`);
console.log('I was clicked for save');
Session.set('editCommentId', null);
server/comments/publish.js
updateComment: function (commentContent, commentId, fritkotId) {
let currentUserId = Meteor.userId();
Comments.update({
body: commentContent,
author: currentUserId,
fritkotId: fritkotId,
createdAt: new Date()
});
}
collections/comments.js
// Permissions
Comments.allow({
insert: () => false,
// update: (userId, doc) => { return !! userId; },
update: () => false,
remove: () => false
});
Comments.deny({
insert: () => true,
update: () => true,
// update: (userId, doc) => { return !! userId; },
remove: () => true
});