Created
December 7, 2021 08:06
-
-
Save hieptl/a4f4259277647e536c183e5d3c6edb35 to your computer and use it in GitHub Desktop.
signup.js - create cometchat account - ZocDoc Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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