Skip to content

Instantly share code, notes, and snippets.

@jetaggart
Created July 12, 2020 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetaggart/eba16cba7fb6dfd1fb9154558615068c to your computer and use it in GitHub Desktop.
Save jetaggart/eba16cba7fb6dfd1fb9154558615068c to your computer and use it in GitHub Desktop.
// 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,
email
})
})
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