I have been using MailWizz to send emails. I tried to use the following test.js
to add a new subscriber [email protected]
to an existing list (I’m sure it does not exist in the list):
const { ListSubscribers } = require('node-mailwizz');
const config = {
publicKey: 'key',
secret: 'key',
baseUrl: 'http://mail.mycompany.com/api'
}
const subscribers = new ListSubscribers(config);
function createSubscriber() {
const userInfo = { EMAIL: "[email protected]" };
subscribers.create({
listUid: "en804x0lnrf1f",
data: userInfo
}).then(result => {
console.log('Subscriber created:', result);
}).catch(err => {
console.error('Error:', err);
})
}
createSubscriber()
However, running node test.js
returned
Error: {
status: 'error',
error: 'Only POST requests allowed for this endpoint.'
}
Does anyone know what’s the correct way to create a new subscriber by API in node?