vote()
vote(...args: VoteInputArgs): Promise<Poll>
Submit a vote for a poll.
Parameters:
...args(VoteInputArgs): An array containing the following information in order:pollTypeId(PollTypes): The type of the poll (SingleChoice or MultipleChoice).pollId(EntryIdType): The ID of the poll for which to submit the vote.optionIds(EntryIdType[]): An array of option IDs representing the user's vote.userId(string): The unique user identifier.
Returns:
A
Promiseresolving to the updated poll object (Poll), including information such as the poll ID, name, creation date, associated poll type, and updated vote counts.
Example:
const voteArgs = [PollTypes.SingleChoice, 1, [1], 'user-123'];
try {
const updatedPoll = await pollz.polls.vote(...voteArgs);
console.log('Vote Submitted:', updatedPoll);
} catch (error) {
console.error('Failed to submit vote:', error.message);
}The vote method allows users to submit their votes for a specific poll. Provide the poll type (pollTypeId), the poll ID (pollId), an array of option IDs representing the user's vote (optionIds), and the unique user identifier (userId).
The method returns a Promise resolving to the updated poll object (Poll), which includes details such as the poll ID, name, creation date, associated poll type, and updated vote counts for each option.
Note: Ensure that the provided poll type, poll ID, option IDs, and user ID are valid and correspond to an existing poll in the system.
Last updated