Created
August 14, 2020 19:50
-
-
Save isaidspaghetti/afe26e31ab03ef2bb3c41853e46a37f7 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:14 | |
const register = async (e) => { | |
try { | |
e.preventDefault(); | |
const response = await fetch('http://localhost:8080/customer-login', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
body: JSON.stringify({ | |
firstName, | |
lastName, | |
email, | |
}), | |
}); | |
const { customerId, customerToken, channelId, streamApiKey } = await response.json(); | |
const chatClient = new StreamChat(streamApiKey); | |
await chatClient.setUser( | |
{ | |
id: customerId, | |
name: firstName, | |
}, | |
customerToken, | |
); | |
const channel = chatClient.channel('messaging', channelId); | |
setChatClient(chatClient); | |
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