简体   繁体   中英

Error Parse SDK: Cannot sign up user with an empty name

I am trying to sign up users with the Parse SDK. My keys are correct and I have used my own code as well as the "Signing Up" code straight from Parse Quickstart Tutorial and I keep getting this error message:

Cannot sign up user with an empty name.

I have even hardcoded values into the signUp function, and printed the values (and typeof) out to the console for accuracy, but still not luck. Here's a snippet of the function I created, it's practically straight out of the tutorial.

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);
    }
});

You should set the username :

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

From Parse Quickstart Tutorial that you mentioned:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM