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

标签 javascript rest parse-platform

我正在尝试使用 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/

相关文章:

javascript - 操作内存中 jQuery 对象的 textarea 值

ios - PFQuery 没有获取与类相关的 PFUser

swift - 查询解析,如何在 Swift 的 tableView 单元格中打印数据?

ios - 仅从 Parse 中获取 PFObject 的一些键以节省数据量 - iOS

javascript - 使用 jsonData 和 count 变量时出现 NaN 问题

Javascript - 我如何等待 10 秒才能返回 promise ?

javascript - react : Pass `this` to onClick with multiple functions

rest - 多页文档作为 REST 上的图像

http-status-codes - REST API 中可能出现的 HTTP 状态代码的完整间隔是多少?

rest - 'Query String Parameters' 是 header 的一部分吗?