Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Version 4
Home
/
Chat
/
JavaScript
/
Message

Retrieve a list of voters

You can retrieve a list of voters for a poll option using the createPollVoterListQuery() method or the sb.createPollVoterListQuery() method.

// One way to retrieve a list of voters for a poll.
const query: PollVoterListQuery = channel.createPollVoterListQuery(pollId, pollOptionId);
const voters: User[] = await query.next();

// Another way to retrieve a list of voters for a poll.
const params: PollVoterListQueryParams = {
  channelUrl: channel.url,
  channelType: ChannelType.GROUP,
  pollId: poll.id,
  pollOptionId: poll.options[0].id,
  limit: 10,
};
const query: PollVoterListQuery = sb.createPollVoterListQuery(params);
const voters: User[] = await query.next();

PollVoterListQueryParams

Parameter nameTypeDescription

pollId

number

Specifies the unique ID of a poll.

pollOptionId

number

Specifies the unique ID of a poll option.

channelType

ChannelType

Specifies the type of the channel.

channelUrl

string

Specifies the URL of the channel.

limit?

number

Specifies the number of results to retrieve per page. Acceptable values are 1 to 100, inclusive. (Default: 20)