Quickstart

Quickstart Guide for pollz-js Node.js SDK

Welcome to the pollz-js Node.js SDK, a powerful tool for integrating Pollz functionality into your applications. This quickstart guide will walk you through the basic steps to get started with the SDK and quickly incorporate polling features into your Node.js project.

Installation

First, install the pollz-js SDK in your Node.js project using npm:

npm install pollz-js

Initialize the SDK

To use the pollz-js SDK, you need to initialize it with your application credentials. Obtain your appId and appSecret from the Pollz platform.

const { PollzSDK } = require('pollz-js');

// Initialize pollz-js SDK
const pollz = new PollzSDK();
const initInput = {
  appId: 'your-app-id',
  appSecret: 'your-app-secret',
};

try {
  await pollz.init(initInput);
  console.log('pollz-js SDK initialized successfully!');
} catch (error) {
  console.error('Failed to initialize pollz-js SDK:', error.message);
}

Create a Poll

Now that the SDK is initialized, you can create a new poll with options.

Vote in a Poll

Users can now cast their votes in the created poll.

Get Poll Information

Retrieve information about a specific poll or a list of all polls.

Real-time Poll Updates

Listen for real-time updates to a specific poll. This is useful for scenarios where you want to keep your application updated with the latest poll data.

Congratulations! You have completed the pollz-js Node.js SDK quickstart guide. Explore the SDK's comprehensive features and customize your integration to suit your application's needs. For detailed information on additional functionalities and options, refer to the full SDK documentation.

Last updated