Meteor方法可以在服务器端和客户机端运行(
see here
)这里的错误来自客户端:
simulating the effect
意味着客户机正试图对服务器的查询计算一个乐观的答案。
accounts对象在客户端和服务器端都可用,但我敢打赌accounts.setpassword函数仅在服务器中出于安全原因可用。
为了避免错误,您可以将Meteor方法定义放在仅服务器的文件夹中
see here
(就像在这个文件中一样)
app_code/imports/api/accounts/server/methods.js
或者用
if(Meteor.isServer)
see here
像这样的:
if(Meteor.isServer){
Meteor.methods({
setPassword(newPassword, userId) {
check(userId, String);
check(newPassword, String);
if(Meteor.user().isAdmin){
Accounts.setPassword(userId, newPassword);
}
},
});
}