N
Novu2y ago
empe

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
Gali Baum
Gali Baum2y ago
await novu.topics.addSubscribers(topicKey, {subscribers: subscriberIdArray}
);
await novu.topics.addSubscribers(topicKey, {subscribers: subscriberIdArray}
);
Try this @emilpearce
empe
empe2y ago
Thank you! It worked!
Want results from more Discord servers?
Add your server