当尝试定义 Parse Cloud Code 服务器端函数来处理登录时,我在尝试调用它时收到 400 Bad Request。当我查看 Parse 日志时,它记录了错误“失败:ReferenceError:未定义用户”。但是用户是绝对定义的!
下面是LogIn的云代码定义:
Parse.Cloud.define("LogIn", function(request, response)
{
user.logIn(request.params.username, request.params.password,
{
success: function(user)
{
response.success(
{
"success": "Log in successful."
});
},
error: function(user, error)
{
// We must respond with a success in order to access the
// result of the request inside Unity.
response.success(
{
"error": "Log in failed.",
"code": error.code,
"message": error.message
});
}
});
});
在 Unity 中,我调用了 LogIn coud 代码函数:
ParseCloud.CallFunctionAsync<Dictionary<string, object>> ("LogIn", userInfo).ContinueWith (t =>
{
etc.....
}
当我使用用户 sashas123 和 student123 从 Unity 调用上述内容时,我在服务器端 Parse 日志中记录了以下错误:
E2014-09-26T17:06:18.001Z] v8:运行云函数登录,使用:输入:{"username":"sashas123","password":"test"} 失败:ReferenceError:用户未在 main 中定义。 js:43:5
E2014-09-26T17:38:50.474Z] v10:运行云功能登录:
输入:{"username":"student123","password":"test"} 失败:ReferenceError:用户未在 main 中定义。 js:43:5
数据浏览器中的以下快照显示上述用户已明确定义:
![解析用户类][1]
通过 Cloud Code 在服务器端调用 user.LogIn 是否有任何问题,或者这是 Unity 问题?