我试图添加用户但我一直收到此错误:
"发生了意外的注册异常以下操作:"创建我的应用用户"无法执行:只能调用函数只能调用函数只能调用函数"
不确定问题是什么......
创建我的应用用户操作
/* globals
$http - Service for AJAX calls
CONSTS - CONSTS.apiUrl for Backands API URL
Config - Global Configuration
*/
'use strict';
function backandCallback(userInput, dbRow, parameters, userProfile) {
// When a new user registers, add her to the users object.
// If you are using a different object for your users then change this action accordingly.
if (parameters.sync)
return {};
if (!parameters)
parameters = {};
parameters.email = userInput.Username;
parameters.firstName = userInput.FirstName;
parameters.lastName = userInput.LastName;
try{
var response = $http({
method: "POST",
url:CONSTS.apiUrl + "/1/objects/users",
params: {parameters: {"sync": true}},
data: parameters,
headers: {"Authorization": userProfile.token}
});
}
catch(err) {
// register user even if there is an error or no users object
}
return {};
}
答案 0 :(得分:3)
Backand云代码在自定义javascript引擎上运行,因此它有一些限制。
确保您在完成此功能后没有任何代码, 甚至在评论中。
您的操作必须只是上面或下面没有任何代码或评论的功能。
如果要在代码中添加其他功能,可以将其添加为内部函数,如下所示:
function backandCallback(userInput, dbRow, parameters, userProfile) {
function foo(){
// do something great
}
foo();
return {};
}