ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

javascript-错误解析SDK:无法使用空名称注册用户

2019-11-21 14:36:18  阅读:227  来源: 互联网

标签:parse-platform rest javascript


我正在尝试使用Parse SDK注册用户.我的密钥是正确的,我使用了自己的代码以及直接从Parse Quickstart Tutorial开始的“ Signing Up”代码,但我不断收到此错误消息:

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.

标签:parse-platform,rest,javascript
来源: https://codeday.me/bug/20191121/2052360.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有