Registration Success Only Gives Error Message

I'm following the Login-Registration App template. Only difference is I'm adding some additional fields to the UserProfile collection.

When I test using the appery tester or test from a mobile device, the correct data is added to both the Users collection and the UserProfile collection but the error message "Registration failed. Please try again." comes up.

Here is the Server Code from the RegisterNewUser_RegisterNewUser:

// This script requires creating a custom UserProfile collection. Then creating
// a 'user_profile' column in Users collection with Pointer type
// referencing UserProfile collection.
// See more in tutorial:

var databaseId = "5a3d431a00c48f257d87a862";
var username = request.get("username");
var password = request.get("password");
var email = request.get("email");
var company = request.get("company");
var phone = request.get("phone");
var deliveryaddress = request.get("deliveryaddress");
var city = request.get("city");
var state = request.get("state");
var postalcode = request.get("postalcode");

try {

// Register new user
var userLoginInfo = DatabaseUser.signUp(databaseId, {
"username": username,
"password": password

// Save additonal registration information into 'UserProfile' custom collection
var userProfileInfo = Collection.createObject(databaseId, "UserProfile", {
"email": email,
"company": company,
"phone": phone,
"deliveryaddress": deliveryaddress,
"city": city,
"state": state,
"postalcode": postalcode
}, userLoginInfo.sessionToken);

// Link Users and UserProfile collection
DatabaseUser.update(databaseId, userLoginInfo._id, {
"toProfile": {
"collName": "UserProfile",
"_id": userProfileInfo._id
}, userLoginInfo.sessionToken);

// Create a response for this script
var userData = {
"session": userLoginInfo.sessionToken,
"username": username,
"email": email,
"company": company,
"phone": phone,
"deliveryaddress": deliveraddress,
"city": city,
"state": state,
"postalcode": postalcode

response.success(userData, "application/json");

} catch (error) {

"message": "Registration failed. Please try again."
}, 400);
1 person has
this problem