使用parse api注册(401(未经授权))

时间:2016-03-15 05:56:21

标签: javascript parse-platform google-chrome-app parse-server

我正在尝试在解析服务器上注册用户。我已将解析对象初始化为applicationid和key,但我无法注册。我正在获取未授权错误。我正在使用chrome app。我也允许在mainifest文件中获得权限。

  Parse.initialize("app_id", "key");
var username= "jitendra.singh@gmail.com";
var password = "singh";

Parse.User.signUp(username, password, {}, {
    success: function (user) {
        console.log("Yay!");
    },
    error: function (user, error) {
         console.log("Error: " + error.code + " " + error.message);
    }
});

错误: POST https://api.parse.com/1/users 401(未经授权)

2 个答案:

答案 0 :(得分:0)

初始化你的解析

 Parse.initialize("app_id", "key");

调用此函数

 function Signup(userInfo){
  var user = new Parse.User();
  // set the properties of the user
  user.set("username", "username");
  user.set("password", "password");
  user.set("email", "emailid");
  // Create a custom field for the user (there is no limit to the number of custom records)
  user.set("score", 0);
 user.signUp(null, {
   success: function(user) {
         // return the success response
         console.log("Success!");
   },
   error: function(user, error) {
          // return the error response
          console.log("Error: " + error.code + " " + error.message);
    }
 });    
}

答案 1 :(得分:0)

如果您使用的是解析服务器,则需要更改初始化

的JavaScript

Parse.initialize("YOUR_APP_ID");
Parse.serverURL = 'http://localhost:1337/parse'

请参阅https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide#migrating

相关问题