I'm trying to set up a newsletter subscription form on a site hosted on Netlify. When a user submits an email address, I'd like it to be added to my contact list on Mailjet. To do this without a third-party service like Zapier, it's necessary to use a Netlify function with environment variables.
I have searched and tried everything but just can't get this to work.
Here is a promising tutorial for MailerLite, which I'm willing to try, but I couldn't get this to work either. Here is another for some different email services, and here is yet another tutorial for doing so with Buttondown.
I don't know javascript well enough to adapt these to Mailjet or MailerLite.
Can anyone please provide functional code that can simply be copy-pasted into my /functions/subscribeToMailjet.js
or /functions/subscribeToMailerLite.js
file?