Skip to content

Instantly share code, notes, and snippets.

@freshlogic
Last active May 24, 2016 04:31
Show Gist options
  • Save freshlogic/dd0ff50d927b289c7821934e52fd3c01 to your computer and use it in GitHub Desktop.
Save freshlogic/dd0ff50d927b289c7821934e52fd3c01 to your computer and use it in GitHub Desktop.
Error 212
const mcapi = require('mailchimp-api');
const mailchimp = new mcapi.Mailchimp(process.env.mailchimpApiKey);
const mailchimpListId = process.env.mailchimpListId;
var subscribe = {
double_optin: false,
email: { email: 'test@mediocre.com' },
id: mailchimpListId
};
mailchimp.lists.subscribe(subscribe, (member) => {
var unsubscribe = {
email: { leid: member.leid },
id: mailchimpListId
};
mailchimp.lists.unsubscribe(unsubscribe, () => {
var resubscribe = {
email: { leid: member.leid },
id: mailchimpListId
};
mailchimp.lists.subscribe(subscribe, () => {
console.log('success');
}, err => {
return console.error('resubscribe error', err);
});
}, err => {
return console.error('unsubscribe error', err);
});
}, err => {
return console.error('subscribe error', err);
});
/*
resubscribe error { status: 'error',
code: 212,
name: 'List_InvalidUnsubMember',
error: 'test@mediocre.com has unsubscribed, and cannot be resubscribed by you. To prevent false spam complaints, they\'ll need to resubscribe of their own free will.' }
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment