Edit Mailchimp API to also include Tag in Email Submissions
Budget: $30 – $250 CAD
Currently,
I have a cloud function in which I also want to add a tag that I define to email submissions. My current function minus the api keys is the below. I wish to edit this to include tags on submssions:
A stock overflow submission about this topic: https://stackoverflow.com/questions/52298226/how-to-add-tags-to-mailchimp-subscriber-via-the-api
CURRENT FUNCTION BELOW:
const express = require("express");
const app = express();
const axios = require("axios");
app.use(express.json());
app.use(function (_, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
res.header(
"Access-Control-Allow-Headers",
"Content-Type, Authorization, Content-Length, X-Requested-With"
);
next();
});
app.post("/subscribe", async (req, res) => {
try {
const email = req.query.email;
const subscriber = {
members: [
{
email_address: email,
status: "subscribed",
},
],
};
await axios.post(
"https://us20.api.mailchimp.com/3.0/lists/MYLISTIDHERE",
subscriber,
{
headers: {
Authorization: "auth MYAUTHEYHERE",
},
}
);
res.json({ msg: "success" });
} catch (err) {
console.log(err);
}
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`server is running on port ${PORT}`));
I have a cloud function in which I also want to add a tag that I define to email submissions. My current function minus the api keys is the below. I wish to edit this to include tags on submssions:
A stock overflow submission about this topic: https://stackoverflow.com/questions/52298226/how-to-add-tags-to-mailchimp-subscriber-via-the-api
CURRENT FUNCTION BELOW:
const express = require("express");
const app = express();
const axios = require("axios");
app.use(express.json());
app.use(function (_, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
res.header(
"Access-Control-Allow-Headers",
"Content-Type, Authorization, Content-Length, X-Requested-With"
);
next();
});
app.post("/subscribe", async (req, res) => {
try {
const email = req.query.email;
const subscriber = {
members: [
{
email_address: email,
status: "subscribed",
},
],
};
await axios.post(
"https://us20.api.mailchimp.com/3.0/lists/MYLISTIDHERE",
subscriber,
{
headers: {
Authorization: "auth MYAUTHEYHERE",
},
}
);
res.json({ msg: "success" });
} catch (err) {
console.log(err);
}
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`server is running on port ${PORT}`));