Last active
December 17, 2021 12:37
-
-
Save hieptl/a6853bc25df06f00a60026d4509cae29 to your computer and use it in GitHub Desktop.
doctordetail.js - 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 createCometChatFriend = async () => { | |
| if (!user || !item) { | |
| return; | |
| } | |
| setIsLoading(true); | |
| const cometChatAppId = `${cometChatConfig.cometChatAppId}`; | |
| const cometChatAppRegion = `${cometChatConfig.cometChatRegion}`; | |
| const cometChatApiKey = `${cometChatConfig.cometChatRestApiKey}`; | |
| const url = `https://${cometChatAppId}.api-${cometChatAppRegion}.cometchat.io/v3/users/${user.id}/friends`; | |
| const options = { | |
| method: "POST", | |
| headers: { | |
| Accept: "application/json", | |
| "Content-Type": "application/json", | |
| appId: cometChatAppId, | |
| apiKey: cometChatApiKey, | |
| }, | |
| body: JSON.stringify({ accepted: [item.id] }), | |
| }; | |
| try { | |
| const response = await fetch(url, options); | |
| if (response) { | |
| alert(`The appointment was created succesfully`); | |
| } else { | |
| alert(`Failure to add create the appointment`); | |
| } | |
| setIsLoading(false); | |
| setHasCreatedAppointment(() => true); | |
| } catch (error) { | |
| console.log(error); | |
| setIsLoading(false); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment