📊
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. polls

get()

get(id: EntryIdType, orderOptionsBy = OrderBy.Asc): Promise<PollWithOptions>

Get information about a specific poll.

Parameters:

  • id (EntryIdType): The ID of the poll for which you want to retrieve information.

  • orderOptionsBy (OrderBy, optional): The order in which to retrieve poll options. Default is OrderBy.Asc (ascending).

Returns:

  • A Promise resolving to the poll object (PollWithOptions) containing details about the specified poll.

Example:

const pollIdToRetrieve = 1;

try {
  const retrievedPoll = await pollz.polls.get(pollIdToRetrieve);
  console.log('Retrieved Poll:', retrievedPoll);
} catch (error) {
  console.error('Failed to retrieve poll:', error.message);
}

The get method allows you to retrieve detailed information about a specific poll by providing its unique ID (id). You can also specify the order in which the poll options should be retrieved using the optional parameter orderOptionsBy.

The method returns a Promise resolving to the poll object (PollWithOptions), which includes information such as the poll ID, name, creation date, associated poll type, options, total votes, and more.

Note: Ensure that the provided id corresponds to an existing poll in the system.

Previouscreate()NextgetAll()

Last updated 1 year ago