Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created December 7, 2021 08:06
Show Gist options
  • Select an option

  • Save hieptl/a4f4259277647e536c183e5d3c6edb35 to your computer and use it in GitHub Desktop.

Select an option

Save hieptl/a4f4259277647e536c183e5d3c6edb35 to your computer and use it in GitHub Desktop.
signup.js - create cometchat account - ZocDoc Clone
const createCometChatAccount = async ({ id, fullname, avatar }) => {
try {
const authKey = `${cometChatConfig.cometChatAuthKey}`;
const user = new cometChat.User(id);
user.setName(fullname);
user.setAvatar(avatar);
const cometChatUser = await cometChat.createUser(user, authKey);
if (cometChatUser) {
showMessage('Info', `${fullname} was created successfully! Please sign in with your created account`);
setIsLoading(false);
setUserAvatar(null);
} else {
setIsLoading(false);
setUserAvatar(null);
}
} catch (error) {
showMessage('Error', 'Fail to create your CometChat user, please try again');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment