Utilizing Parse.com as the database for my app, I am working on streamlining the code in my signup view.
user.set("username",$scope.user.email);
user.set("email",$scope.user.email);
user.set("password",$scope.user.password);
user.signUp(null,
{ success: function(user) {
$ionicLoading.hide();
$scope.state.success = true;
}, error: function(user, error) {
$ionicLoading.hide();
if (error.code == 125) { $scope.error.message = "Please specify a valid email address"; }
else if (error.code == 202) { $scope.error.message = "The email address is already registered"; }
else { $scope.error.message = error.message; }
$scope.$apply();
}
});
My query is: what exactly should the first parameter be? I have not come across any examples on Parse.com where the first parameter is null. Furthermore, I have not been able to find detailed documentation on the .signUp()
method.
My gut feeling suggests that the parameter expects user data in a JSON format, but I lack certainty.
EDIT: Resolution:
var user = new Parse.User();
user.signUp({
"username": $scope.user.email,
"email": $scope.user.email,
"password": $scope.user.password
}, {
success: function(user)
{ $ionicLoading.hide();
$scope.state.success = true;
},
error: function(user, error)
{ $ionicLoading.hide();
if (error.code == 125) { $scope.error.message = "Please specify a valid email address"; }
else if (error.code == 202) { $scope.error.message = "The email address is already registered"; }
else { $scope.error.message = error.message; }
$scope.$apply();
}
});