Initializing your app

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 Pollz platform.

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

  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.

Last updated