📊
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
  • Guide: Initializing the pollz-js SDK
  • Prerequisites
  • Initialize the SDK
  1. Guides

Initializing your app

PreviousGuidesNextCreate a Poll

Last updated 1 year ago

Guide: Initializing the pollz-js SDK

Prerequisites

Before you proceed with initializing the pollz-js SDK, ensure that you have the following prerequisites in place:

  1. Pollz Account: You must have a Pollz account to obtain the necessary appId and appSecret required for SDK initialization. If you don't have an account, sign up on the .

  2. Node.js Installed: Make sure you have Node.js installed on your development machine. You can download Node.js from .

  3. npm Package Manager: The SDK is installed using npm (Node Package Manager), which comes bundled with Node.js. Ensure that npm is available in your development environment.

Initialize the SDK

To use the pollz-js SDK in your Node.js application, follow these steps:

Step 1: Install the SDK

npm install pollz-js

This command installs the pollz-js package and its dependencies in your project.

Step 2: Import the SDK

In your Node.js application, import the pollz-js SDK:

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

Step 3: Initialize the SDK

Create an instance of the PollzSDK class and use the init method to initialize the SDK with your application credentials (appId and appSecret):

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);
}

Replace 'your-app-id' and 'your-app-secret' with the actual credentials obtained from the Pollz platform.

Congratulations! You have successfully initialized the pollz-js SDK. Now you can explore the SDK's features and integrate Pollz functionality into your Node.js application.

Pollz platform
https://nodejs.org/