Update User Object¶
User property values of the logged in users can be updated with an API operation described below. This operation is useful if an application needs to provide to the users the functionality for updating user profiles and registration properties. A user must be logged in in order to update his registration properties.
Non-blocking Method Signature¶
Backendless.UserService.update( user )
.then( function( updatedUser ) {
})
.catch( function( error ) {
});
where
Argument | Description |
---|---|
user |
an instance of the Backendless.User class which contains property values to be updated for the account. |
updatedUser |
updated instance of Backendless.User . |
error |
either an error from the then block or an error returned by the server. |
Blocking Method Signature¶
var updatedUser = Backendless.UserService.updateSync( user );
where
Argument | Description |
---|---|
user |
an instance of the Backendless.User class which contains property values to be updated for the account. |
updatedUser |
updated instance of Backendless.User . |
Errors¶
The following errors may occur during the Update User Properties API call. See the Error Handling section for details on how to retrieve the error code when the server returns an error.
Error Code |
Description |
---|---|
2002 |
Version is disabled or provided wrong application info (application id or secret key) |
3018 |
The property marked as "identity" is being updated and another user already has the specified value which must be unique. |
3024 |
General "update registration" error. Error message should contain additional details. |
3028 |
User is not logged in. |
3029 |
Cannot modify properties of another user. Returned when one user is logged and the call attempts to modify properties of another user. |
3030 |
Unable to locate user account - invalid user id. |
3031 |
A new "dynamic" property is being added, but dynamic property definition is disabled. |
3045 |
Required properties in the provided object do not contain values. |
// do not forget to call Backendless.initApp( appId, jsAPIKey ) in the app initialization code
function updateUser(user) {
user.address = "123 Main St";
return Backendless.UserService.update( user );
}
function userUpdated( user ) {
console.log( "user has been updated" );
}
function gotError( err ) {
console.log( "error message - " + err.message );
console.log( "error code - " + err.statusCode );
}
Backendless.UserService.login( login, password )
.then( updateUser )
.then( userUpdated )
.catch( gotError ) );