Create a Poll
Guide: Creating a Poll with pollz-js SDK
Prerequisites
Create a Poll
Step 1: Import the SDK
const { PollzSDK, PollTypes } = require('pollz-js');Step 2: Create a Poll
const pollz = new PollzSDK();
// Replace 'your-app-id' and 'your-app-secret' with actual credentials
const initInput = {
appId: 'your-app-id',
appSecret: 'your-app-secret',
};
// Initialize the SDK
await pollz.init(initInput);
// Create a poll
const createPollInput = {
name: 'Favorite Programming Language',
options: ['JavaScript', 'Python', 'Java', 'TypeScript'],
pollTypeId: PollTypes.MultipleChoice, // or PollTypes.SingleChoice
};
try {
const createdPoll = await pollz.polls.create(createPollInput);
console.log('Poll created successfully:', createdPoll);
} catch (error) {
console.error('Failed to create poll:', error.message);
}Last updated