У меня есть форма и вы хотите отправить ее содержимое на сервер при отправке. Я нашел аналогичный вопрос здесь 1, который предлагает использовать запрос POST, но я не уверен, как это сделать. Вот мой код стороне клиента:Как я могу извлечь данные формы на сервере?
<form method='post' action='http://localhost:8080' >
<textarea id='chatHistory'></textarea>
<br/><br/>
<div class="demo">
<div class="ui-widget">
<input id="tags" size="50" type="text" />
<input type="submit" value="Send" style="height:40px;width:120px;font-size:18px;" />
</div>
</div>
</form>
Server Side:
app.post('/', function(req,res)
{
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "gmail",
auth: {
user: "[email protected]",
pass: "password"
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: "Suggestion Box ✔ <[email protected]>", // sender address
to: "[email protected]", // list of receivers
subject: "Hello ✔",
text: req.chatHistory.value
};
// send mail with defined transport object
smtpTransport.sendMail(mailOptions, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
});
});
Тело почты не наполняется значением из client.I думаю, что проблема здесь: REQ. chatHistory.value
Как я могу получить значение chatHistory на стороне сервера?
Просто понял это моменты назад, получил это работает. – Aravind