I just started this all API thing- I'm trying to upload data to Mailchimp using their API. I'm not getting any error while running my server, but the data won't get updated (I do get the values from the html form and they get displayed in the hyper terminal) that's my code
const bodyParser=require("body-parser");
const request=require("request");
const https=require("https");
const app=express();
app.use(express.static("public"));
app.use(bodyParser.urlencoded({extended:true}));
app.get("/",function(req,res)
{
res.sendFile(__dirname+"/signup.html");
});
app.post("/",function(req,res)
{
const firstName=req.body.Fname;
const lastName=req.body.Lname;
const email=req.body.email;
console.log(firstName,lastName,email);
const data=
{
members:[
{
email_adress:email,
status:"subscribed",
merge_fields:
{
FNAME:firstName,
LNAME:lastName
}
}
]
};
const jsonData=JSON.stringify(data);
const url="https://us8.api.mailchimp.com/3.0/lists/b8e36ded50";
const options=
{
methods:"POST",
auth:"lidor:56599763339503b7bac161913940d98d-us8"
}
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,function()
{
console.log("server has started on port 3000");
});
please help me !!