Not able to set/upload user avatar using Amity Web UIKit

Hi there,

I’m using web UIKit for React. i want to upload/set user avatar while registering the user. in the UIKit there is option to set Avatar.

I have tried with web SDK but not able access the current user in React UIKit to update the user information as mentioned in web SDK,

also tried by creating a separate instance in WebUIKit using following code to access currentUser function:

import ASCClient, { ApiEndpoint } from '@amityco/js-sdk'

const client = new ASCClient({ apiKey: 'YOUR_API_KEY', 
                                apiEndpoint: ApiEndpoint.US });

its not work too,
getting error “ASCWebSDK: Only one instance of the SDK Web Client can be created”

Please assist.

Hi @salman - you can use amityClient.updateCurrentUser (https://docs.amity.co/chat/web/users#update-user-information) to update avatarFileId and other user field to update the user’s profile picture.
Please note that to get fileId you’ll need to upload image - see more here Users - Amity Docs

Can you tell me how i can access this without declaring and initialised the variable.

Hi @salman - you’ll need to store the initialized variable ( client = new ASCClient ) in as your state / global variable so you can access it at anytime from any class.