Package Exports
- @input-output-hk/mailchimp-subscribe
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@input-output-hk/mailchimp-subscribe) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Mailchimp subscribe library
A lightweight [Mailchimp](https://mailchimp.com/) subscriber library supporting custom fields. Subscribe emails to your mailing lists.
Contents
Features
- Custom fields
Install
npm install --save @input-output-hk/mailchimp-subscribe
or
yarn add @input-output-hk/mailchimp-subscribe
Finding Mailchimp values
Finding the 'uID' value



Finding the 'audienceID' value



Finding the 'listName' value



Examples
Basic without localization
import subscribe from '@input-output-hk/mailchimp-subscribe'
async function submitForm (email) {
try {
const result = await subscribe({
email,
uID: 'XXXXXXXXX',
audienceID: 'XXXXXXXXX',
listName: 'XXXXXX.XXXX'
})
// Instance of MailChimpSuccess
// result.message is the msg value received from Mailchimp
return result
} catch (error) {
// handle error
// error is instance of MailChimpError when error originates from mailchimp
// error.message is the message returned from Mailchimp if the error originated on mailchimp
return error
}
}
Custom fields
import subscribe from '@input-output-hk/mailchimp-subscribe'
async function submitForm (email) {
try {
await subscribe({
email,
uID: 'XXXXXXXXX',
audienceID: 'XXXXXXXXX',
listName: 'XXXXXX.XXXX',
customFields: {
MY_FIELD: 'value',
MY_SECOND_FIELD: 'value_2'
}
})
// Instance of MailChimpSuccess
// result.message is the msg value received from Mailchimp
return result
} catch (error) {
// handle error
// error is instance of MailChimpError when error originates from mailchimp
// error.message is the message returned from Mailchimp if the error originated on mailchimp
return error
}
}
Specifiying a timeout
import subscribe from '@input-output-hk/mailchimp-subscribe'
async function submitForm (email) {
try {
await subscribe({
email,
uID: 'XXXXXXXXX',
audienceID: 'XXXXXXXXX',
listName: 'XXXXXX.XXXX',
// 6000ms
timeout: 6000
})
// Instance of MailChimpSuccess
// result.message is the msg value received from Mailchimp
return result
} catch (error) {
// handle error
// error is instance of MailChimpError when error originates from mailchimp
// error.message is the message returned from Mailchimp if the error originated on mailchimp
return error
}
}
Contributing
Contributions are welcome, see contributing for more info.