Created
December 23, 2019 14:09
-
-
Save pmbanugo/f8ef6db43c5cee805b4aee70f67cd98a 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
initialiseChatClient = async () => { | |
const response = await fetch("http://localhost:8080/v1/token", { | |
method: "POST", | |
mode: "cors", | |
headers: { | |
"Content-Type": "application/json" | |
}, | |
body: JSON.stringify({ | |
id: this.user.id, | |
name: this.user.name | |
}) | |
}); | |
const streamServerInfo = await response.json(); | |
this.chatClient = new StreamChat(streamServerInfo.apiKey); | |
this.chatClient.setUser(this.user, streamServerInfo.token); | |
this.conversation = this.chatClient.channel("commerce", "conversational-ui"); | |
await this.conversation.watch(); | |
this.conversation.on("message.new", this.onNewMessage; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment