这是简单注册页面的node.js代码
const express = require("express");
const app = express();
const https = require("https");
const bodyparser = require("body-parser");
app.use(express.static("public"));
app.use(bodyparser.urlencoded({extended: true}))
app.get("/", function(req, res){
res.sendFile(__dirname + "/signup.html")
console.log("page routed")
})
app.post("/", function(req, res){
const firstname = req.body.firstname
const lastname = req.body.lastname
const email = req.body.email
// const https = require("https")
// console.log(firstname, lastname, email)
var data = {
members: [{
email_address: email,
status: "subscribed",
merge_fields: {
FNAME: firstname,
LNAME: lastname
}
}]
};
const jsonData = JSON.stringify(data);
const url ="https://usx.admin.mailchimp.com/3.0/list/list_id"
const options = {
method:"POST",
auth: "7x:apikey-usx"
}
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(3000, () => {
console.log("server is running at 3000")
})
我也是新手,我已经阅读了所有可能对我来说可能的内容我知道错误是如何引起的 但我不知道如何修复这段代码,请用简单的语言解释一下