Skip to content

Instantly share code, notes, and snippets.

@pmbanugo
Created January 6, 2020 15:59
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 pmbanugo/ce45810721485b0412514e64a0d020c9 to your computer and use it in GitHub Desktop.
Save pmbanugo/ce45810721485b0412514e64a0d020c9 to your computer and use it in GitHub Desktop.
private conversation: Channel;
async initialiseChatClient(): Promise<void> {
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.user.avatarUrl = streamServerInfo.user.image;
const chatClient = new StreamChat(streamServerInfo.apiKey);
chatClient.setUser(this.user, streamServerInfo.token);
this.conversation = 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