Vote for a Poll
Guide: Voting in a Poll with pollz-js SDK
Prerequisites
Vote in a Poll
Step 1: Import the SDK
const { PollzSDK, PollTypes } = require('pollz-js');Step 2: Vote in 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);
// Replace with the actual poll ID and option IDs
const pollId = 1;
const optionIds = [1, 2];
// Replace with a unique user identifier
const userId = 'user-123';
try {
await pollz.polls.vote(
PollTypes.MultipleChoice,
pollId,
optionIds,
userId
);
console.log('Vote submitted successfully!');
} catch (error) {
console.error('Failed to submit vote:', error.message);
}Last updated