Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor Accounts.createUser()在客户端上返回未定义_Meteor - Fatal编程技术网

Meteor Accounts.createUser()在客户端上返回未定义

Meteor Accounts.createUser()在客户端上返回未定义,meteor,Meteor,我在我的meteor网站上有一个注册/登录过程。我有一个表单来注册新用户和一个表单来登录用户 I通过在服务器端初始化用户 Accounts.createUser({用户名:“myusername”,密码:“mypassword”}); 我还可以通过客户机上的我的loginform登录到我的dummyusers Meteor.loginWithPassword(用户名、密码) 我不知道为什么,但出于某种原因,我无法在客户端创建新用户。如果我打电话 Accounts.createUser({us

我在我的meteor网站上有一个注册/登录过程。我有一个表单来注册新用户和一个表单来登录用户

I通过在服务器端初始化用户

Accounts.createUser({用户名:“myusername”,密码:“mypassword”});
我还可以通过
客户机上的我的loginform登录到我的dummyusers

Meteor.loginWithPassword(用户名、密码)
我不知道为什么,但出于某种原因,我无法在客户端创建新用户。如果我打电话

Accounts.createUser({username:username,password:password});
它返回未定义的
(safari)

我检查了输入字符串(用户名、密码),它不会生成错误,即使是像这样的纯字符串

Accounts.createUser({用户名:“test”,密码:“pass”});
在客户端控制台上返回未定义的

我通过以下方式发布并订阅了我的用户:

服务器

Meteor.publish('users',function(){ log(“服务器日志:发布所有用户”); return Meteor.users.find(); });
客户

Meteor.subscribe(“用户”);
我还可以在客户端控制台上使用
count()
用户,但我不能使用
Accounts.createUser()
,因此createUser()函数甚至不能在我的控制台中工作

为什么我不能在
客户机/控制台上使用
Accounts.createUser()

是客户机上的一个异步函数,因为它需要查询服务器以知道它是否实际成功(用户名或电子邮件可能已经在使用中)。异步函数的返回值总是
未定义的
,因此结果是预期的

如果从一个空项目和一个空数据库开始,则可以执行以下操作:

Accounts.createUser({用户名:'dave',密码:'password'});
它将返回
undefined
,但是对
Meteor.userId()
的后续调用应返回一个字符串

为了确定调用是否成功,您需要提供回调:

Accounts.createUser({username:'dave',password:'password'},函数(err){
如果(错误)
控制台日志(err);
其他的
console.log('success!');
});

帮我一个忙,使用这个
回调函数
来知道错误是从哪里来的,
Accounts.createUser({username:username,password:password},function(error,result){if(error){console.log(error.reason}});
有趣的错误
禁止注册
看起来像是一些未使用的帐户ui包(meteoric)是问题。删除了它们。thx用于错误的破解。我正在寻找一个如何在手动创建用户时进行回调的示例。谢谢。