gpt4 book ai didi

javascript - 错误解析SDK : Cannot sign up user with an empty name

转载 作者:行者123 更新时间:2023-11-29 10:43:20 25 4
gpt4 key购买 nike

我正在尝试使用 Parse SDK 注册用户。我的 key 是正确的,我使用了自己的代码以及直接来自 Parse Quickstart Tutorial 的“注册”代码我不断收到此错误消息:

Cannot sign up user with an empty name.

我什至将值硬编码到 signUp 函数中,并将值(和 typeof)打印到控制台以确保准确性,但仍然不走运。这是我创建的函数的片段,它实际上直接来自教程。

var newUserEmail    = document.getElementById("new-user-email").value;
var newUserPassword = document.getElementById("new-user-password").value;
var user = new Parse.User();
user.set("email", newUserEmail);
user.set("password", newUserPassword);
user.set("name", "no name");
user.signUp(null, {
success: function(user) {
console.log("New user signed up successfully!");
},
error: function(user, error) {
console.log("You messed up. Error: " + error.message);
}
});

最佳答案

您应该设置用户名:

user.set("username", "my name");

来自 Parse Quickstart Tutorial你提到的:

If a signup isn't successful, you should read the error object that is returned. The most likely case is that the username or email has already been taken by another user. You should clearly communicate this to your users, and ask them try a different username.

You are free to use an email address as the username. Simply ask your users to enter their email, but fill it in the username property — Parse.User will work as normal. We'll go over how this is handled in the reset password section.

关于javascript - 错误解析SDK : Cannot sign up user with an empty name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24691154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com