mailchimp-lite
A lightweight wrapper for Mailchimp's v2 and v3 apis.
npm i mailchimp-lite --save
Usage
let Mailchimp = require('mailchimp-lite');
let mailchimp = new Mailchimp({
key: process.env.MAILCHIMP_API_KEY,
datacenter: MAILCHIMP_DATACENTER
});
mailchimp
.get('/list/my-list-id')
.then((listInstance) => {
console.log(listInstance);
});
mailchimp
.delete('/lists/my-list-id');
return mailchimp.v2.post('/lists/batch-subscribe', {
id: 'my-list-id'
update_existing: true,
double_optin: false,
replace_interests: false,
batch: [
{email: {email: 'freddy@mailchimp.com'}}
]
})
.then((response) => { console.log(response); })
Error Handling
Responses with a non 200-300 status will reject with an Error object. The error has a response
which is the response object from request.
mailchimp
.get('/list/my-list-id')
.catch((error) => {
console.log(error);
console.log(error.response);
});
Contributing
After cloning this repository:
npm i
# run the tests
npm t