目录

User Information

has.getUserProfile

has.getUserProfile(Object object)

Obtains user information. The userInfo object is returned.

Since: 1.0.17

Dependency: HarmonyOS SDK version 6.0.0(20) or later and ROM version 6.0.0 or later

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
userInfo UserInfo User information object.

Error code information

Error Code Error Message
101 context is undefined.
126 getUserProfile is not supported on this device, 20 and higher sdk is required.
11001901

1. getUserProfile error.

2. getUserProfile sync error.

11002001 response data is null.
11002002

1. response state is null.

2. response state is different from authRequest state.

Example:

has.getUserProfile({
  success: (res) => {
    console.info('getUserProfile success', res);
  },
  fail: (err) => {
    console.error('getUserProfile fail', err);
  },
  complete: (res) => {
    console.info('getUserProfile complete', res);
  }
});

UserInfo

User information object.

Since: 1.0.17

Parameter Type Description
nickName string User nickname.
avatarUrl string URL of the user's avatar. If the user does not have an avatar, undefined is returned.