我有这个问题,它告诉我有一个意外的令牌":"。
事情就是它应该在那里,你可以在下面的代码中看到:
Meteor.methods({
addEvent:function(title, description, eventStart, eventEnd, city, country, road){
if(!Meteor.userId()){
throw new Meteor.Error("not-authorized");
}
Events.insert({
title: title,
description: description,
eventStart: eventStart,
eventEnd: eventEnd,
createdAt: new Date(),
username: Meteor.user().username,
owner: Meteor.userId(),
address:{
city: city,
country: country,
road: road
}
});
},
deleteEvent:function(eventId){
var event = Events.findOne(eventId);
if(event.private && event.owner){
throw new Meteor.Error("not-authorized");
}
Events.remove(eventId);
}
},
updateEvent: function(eventId, title, description){
var event = Events.findOne(eventId);
if(event.owner !== Meteor.userId()){
throw new Meteor.Error("not-authorized");
}
Events.update(eventId, {$set: {title: title, description: description}});
}
});
令牌是:在更新事件和函数之间,无论如何我都应该在那里。
答案 0 :(得分:1)
您的问题是deleteEvent
方法中的额外括号。
deleteEvent:function(eventId){
var event = Events.findOne(eventId);
if(event.private && event.owner){
throw new Meteor.Error("not-authorized");
}
Events.remove(eventId);
},