getMembers

View as Markdown

getMembers

  • getMembers(params): Promise<{ members: ChatMemberEntity[] }>

Returns the list of members in the given channel.

Parameters

params
objectRequired

Object containing the parameters of the method.

channel
stringRequired

The channel for which to get the list of members.

Returns

Promise<{ members: ChatMemberEntity[] }>

A promise that resolves to an object containing the list of members in the given channel.

Example

In this example, we fetch all the members in the channel channel1 and print the number of members and the list of members to the console.

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const chatClient = client.chat;
6
7const m = await chatClient.getMembers({ channel: "channel1" });
8
9console.log(`There are a total of ${m.members.length} members in channel1.
10The list of members are: ${m.members.map(m => m.id).join(", ")}`);