qcobjects-lib-mailchimp-api
v0.0.20
Published
QCObjects Lib to subscribe users to a Mailchimp list using official API.
Downloads
9
Maintainers
Readme
QCObjects Lib Mailchimp API
QCObjects Lib to subscribe users to a Mailchimp list using official API.
Instructions
- Install this dependency in your project using npm
npm i --save qcobjects-lib-mailchimp-api
- In your config.json file, create the following settings
{
"mailchimp_api": [
"$MAILCHIMP_API(MAILCHIMP_API_KEY,MAILCHIMP_API_SERVER,MAILCHIMP_API_LIST)"
],
}
Above settings will bring the API Key values from the following environment variables:
MAILCHIMP_API_KEY
MAILCHIMP_API_SERVER
MAILCHIMP_API_LIST
- In the code of your microservice, you can import the module using the Import function
Import ("qcobjects-lib-mailchimp-api");
- Usage instructions:
Inside the microservice function you can use the following code:
let microservice = this; // this is the microservice instance
Promise.all (
CONFIG.get("mailchimp_api").map(
api => mailchimpApi.subscribe(
mailchimpApi.parseApi(api).apiKey,
mailchimpApi.parseApi(api).server,
mailchimpApi.parseApi(api).listId,
formData
))
).then (() => {
microservice.done();
}).catch(e => {
logger.debug(e.toString());
});
Learn more about MailChimp official API in the MailChimp Documentation website
This lib is based on the official MailChimp API (https://github.com/mailchimp/mailchimp-marketing-node)
- Test the integration
npm test
- Start the QCObjects HTTP2 Server
qcobjects-server
If you haven't installed QCObjects before, learn more about Installing QCObjects here