I'm trying to add a User but I keep getting this error:
"An unexpected signup exception occured The following action: "Create My App User" failed to perform: Can only invoke functions Can only invoke functions Can only invoke functions"
Not sure what the issue is...
Create My App User Action
/* 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 {};
}
Backand cloud code run on a custom javascript engine, so it have some restriction.
Ensure you don't have any code after the function, even in comment.
Your action have to be only the function without any code or comment above or under.
If you want to add other function in your code, you can add it as an inner function, like this:
function backandCallback(userInput, dbRow, parameters, userProfile) {
function foo(){
// do something great
}
foo();
return {};
}