sud.getUserInfo
javascript
sud.getUserInfo(object)Gets the user nickname and avatar for display in your game.
Parameters
Object object
| Property | Type | Required | Description |
|---|---|---|---|
| success | function | No | Callback invoked when the call succeeds |
| fail | function | No | Callback invoked when the call fails |
| complete | function | No | Callback invoked when the call finishes, on either success or failure |
Callback Parameters
success
| Property | Type | Description |
|---|---|---|
| nickname | string | User nickname |
| avatar | string | User avatar |
fail
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
complete
Invoked after success or fail, without arguments.
Usage Notes
- Request user information in response to a user action. If the current environment requires authorization, obtain it before requesting the data.
- Read
res.nicknameandres.avatar. The result does not contain anavatarUrlfield. - This API does not return sensitive profile data such as a phone number. Use sud.getUserProfile when you need additional user profile data.
- Handle errors in
failand let the user retry. See Login and User Information Flow for integration guidance.
Example
javascript
sud.getUserInfo({
success(res) {
const nickname = res.nickname;
const avatar = res.avatar;
// Update the in-game user display with nickname and avatar.
},
fail(err) {
console.error('Failed to get user information', err.errCode, err.errMsg);
},
});