我不明白,我创建了这个方法
import { Accounts } from 'meteor/accounts-base';
import SimpleSchema from 'simpl-schema';
import { ValidatedMethod } from 'meteor/mdg:validated-method';
export const createUser = new ValidatedMethod({
name: 'createUser',
validate: new SimpleSchema({
email: { type: String, optional: true },
}).validator(),
run({email}) {
if (this.isSimulation) return true;
;
const userId = Accounts.createUser({ email, password:'coucou' });
return 'ok'
},
});
当我调用它时:
import { createUser } from '../../../api/auth/methods.js'
createUser.call({ email: this.email.value }, function(err, data) {
if(err){
console.log('err: ', err);
}else{
console.log('data: ', data);
}
我在服务器端遇到此错误:
Error: A method named 'createUser' is already defined
所以,如果我更改方法的名称就可以工作。
但是,我想了解
1) 为什么已经定义了“createUser”?
2) 'createUser' 默认方法来自哪里?
谢谢;-)
最佳答案
我发现了这个问题,
当您执行以下操作时,“createUser”来自“accounts-password package”:meteor add account-password
您可以 checkin 您的申请
/MyAPPLICATION/.meteor/local/build/programs/server/packages/accounts-password.js
我们可以找到这个:
Meteor.methods({
createUser: function (options) { ...
关于javascript - TheMeteorChef createUser 方法已经存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45769873/