/ SDKs / JavaScript
SDKs
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
JavaScript
Version 4

Update a poll

Copy link

You can update a specific poll by creating and passing the PollUpdateParams parameters in the channel.updatePoll() method.

JavaScriptTypeScript
const params = {
  title: 'My poll',
  optionTexts: [
    'First option',
    'Second option',
  ],
  data: { text: 'My poll data' },
  isAnonymous: true,
  allowUserSuggestion: true,
  allowMultipleVotes: true,
  closeAt: Math.floor(Date.now() / 1000 + oneDayInSeconds),
};
const updatedPoll = await channel.updatePoll(pollId, params);

PollUpdateParams

Copy link
Parameter nameTypeDescription

title?

string

Specifies the title of a poll.

data?

PollData

Specifies an additional data to accompany the poll. A use case might be to provide explanations for incorrect quiz answers.

isAnonymous?

boolean

Determines whether to make votes anonymous. (Default: false)

allowUserSuggestion?

boolean

Determines whether to allow users to make suggestions. (Default: false)

allowMultipleVotes?

boolean

Determines whether to allow users to vote on more than one poll options. (Default: false)

closeAt?

number

Specifies the time when a poll has closed or will close in Unix seconds.