📊
Pollz
  • Introduction
  • Quickstart
  • Guides
    • Initializing your app
    • Create a Poll
    • Vote for a Poll
    • Retrieve a Poll
    • Manage Poll Options
    • Listen to update
    • Anonymous Poll
  • Components
    • React
    • React Native
    • Embedded
  • API Reference
    • init()
    • pollOptions()
      • addOption()
      • deleteOption()
      • renameOption()
    • anonymous
      • createAnonymousToken()
      • getAnonymousPoll()
      • voteAnonymously()
    • polls
      • create()
      • get()
      • getAll()
      • vote()
      • rename()
      • deleteOne()
      • listen()
    • pollTypes
      • getAll()
  • Tooling
    • Typescript
    • React
      • usePoll()
      • usePolls()
      • usePollz()
      • usePollTypes()
      • useAnonymousPoll()
Powered by GitBook
On this page
  1. API Reference
  2. anonymous

voteAnonymously()

voteAnonymously(anonymousPollToken: string, optionIds: EntryIdType[], userId?: string): Promise<boolean>

Submit an anonymous vote for a poll.

Parameters:

  • anonymousPollToken (string): The anonymous voting token for the target poll.

  • optionIds (EntryIdType[]): An array of option IDs representing the user's vote.

  • userId (string, optional): An optional unique user identifier.

Returns:

  • A Promise resolving to a boolean indicating whether the vote was successfully submitted.

Example:

const voteResult = await pollz.anonymous.voteAnonymously('your-anonymous-token', [1, 2], 'user-123');
console.log('Anonymous Vote Submitted:', voteResult);

The voteAnonymously method enables users to anonymously cast their votes for a specific poll using the provided anonymous voting token. Users can select multiple options (optionIds) and may optionally provide a unique user identifier (userId).

This method returns a boolean value indicating the success of the vote submission. A true value means the vote was successfully recorded, while false indicates an unsuccessful attempt.

Note: Ensure that the provided anonymousPollToken is valid and corresponds to an existing anonymous voting session.

PreviousgetAnonymousPoll()Nextpolls

Last updated 1 year ago