Created
August 19, 2020 23:48
-
-
Save isaidspaghetti/7595ae74d05153bdedac77883444c920 to your computer and use it in GitHub Desktop.
This file contains 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
//frontend/src/Admin.js:23 | |
const register = async (e) => { | |
try { | |
e.preventDefault(); | |
const response = await fetch('http://localhost:8080/admin-login', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
adminId, | |
}), | |
}); | |
const { adminToken, streamApiKey, adminName } = await response.json(); | |
chatClient = new StreamChat(streamApiKey); | |
await chatClient.setUser( | |
{ | |
id: adminName, | |
name: 'Administrator' | |
}, | |
adminToken, | |
); | |
const channel = chatClient.channel('messaging', 'livechat'); | |
await channel.watch(); | |
setChannel(channel); | |
} catch (e) { | |
console.error(e); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment