Created
July 12, 2020 22:39
-
-
Save jetaggart/eba16cba7fb6dfd1fb9154558615068c 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/App.js:15 | |
async function register() { | |
const response = await fetch("http://localhost:8080/registrations", { | |
method: "POST", | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' | |
}, | |
body: JSON.stringify({ | |
firstName, | |
lastName, | |
}) | |
}) | |
const { userId, token, channelId, apiKey } = await response.json(); | |
const chatClient = new StreamChat(apiKey); | |
await chatClient.setUser( | |
{ | |
id: userId, | |
name: email, | |
image: `https://getstream.io/random_svg/?id=${userId}` | |
}, | |
token, | |
); | |
const channel = chatClient.channel('messaging', channelId); | |
setChatClient(chatClient); | |
setChannel(channel) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment