Having a Bad Request when trying to add subscribers to a topic
async function addSubscriberToTopic(apiKey) {
const novu = new Novu(apiKey);
const topicKey = await askQuestion('Enter the topic key: ');
const subscriberIds = await askQuestion('Enter the subscriber IDs (comma-separated): ');
const subscriberIdArray = subscriberIds.split(',');
try {
// Add the subscribers to the topic
await novu.topics.addSubscribers(topicKey, subscriberIdArray);
console.log('Subscribers added to the topic successfully!');
} catch (error) {
console.error('Failed to add subscribers to the topic:', error);
}
}
async function addSubscriberToTopic(apiKey) {
const novu = new Novu(apiKey);
const topicKey = await askQuestion('Enter the topic key: ');
const subscriberIds = await askQuestion('Enter the subscriber IDs (comma-separated): ');
const subscriberIdArray = subscriberIds.split(',');
try {
// Add the subscribers to the topic
await novu.topics.addSubscribers(topicKey, subscriberIdArray);
console.log('Subscribers added to the topic successfully!');
} catch (error) {
console.error('Failed to add subscribers to the topic:', error);
}
}
2 Replies