我尝试使用meteor js从服务器端创建用户,在测试代码时,它会在导航器控制台Error invoking Method 'addNewUser': Internal server error [500]
中向我显示此错误。
这是我的代码:
/imports/api/users/methods.js
:
Meteor.methods({
addNewUser(user) {
console.log(user);
const email = user.emails[0].adresse;
const newUser = {
username: user.username,
email: email,
password: user.password
};
Accounts.createUser(newUser, (err) => {
if (err) {
toastr.error(err.reason,'faild');
// this.done(new Error("Submission failed"));
} else {
toastr.success('Registred with success !', 'welcome');
FlowRouter.go('home');
}
});
}
});
/imports/ui/pages/create-account.js:
AutoForm.hooks({
formCreateAccount: {
onSubmit(user) {
Meteor.call('addNewUser', user);
return false;
}
}
});