In this post I would like to show you a simple demo application which is build on top of express js framework, By following this tutorial you gonna build a subscribe form, through this form user can subscribe to MailChimp subscription list.
Let’s setup your express js application by creating
package.json file and install required dependency libraries by issuing below commands.
Get Download link, by showing love:
[l2g name=”Download Source code” id=”4861″]
By issuing the above commands you have installed dependencies and created you launch file called
index.js. Now open
index.js in your text editor and copy past the below code into it.
Server setup is ready, now issue below commands form command line to start HTTP server.
Then head over to
http://localhost:8080, you will get
Hello World! text on the browser screen.
Create a view file
You need a HTML view to show subscription form to the users, so lets create a directory called
views and then create a pug template file which will hold the subscribe form markup.
Then copy below template markup to
Then import pug into application, register pug template engine with middleware and render above created template for home page.
Now run the application
We need to generate public API key from your MailChimp account and also identify your list ID. If you are not sure how to retrieve those, follow these links from MailChimp Knowledge Base to retrieve your account’s API key and find your list ID.
Now import mailChimp library which you have installed earlier at the beginning of the application setup, update your
index.js file, import
mailchimp-api-v3 module and create post handler route to handle from submissions, implemented logic for subscriptions. Here is the final
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.