【发布时间】:2021-08-30 13:27:43
【问题描述】:
HTML
这是我用来向我的服务器发送请求的表单。
<form action="/compose" method="post">
<div style="margin-bottom: 1rem; margin-top: 2rem;">
<label for="exampleInputEmail1" class="form-label">Title</label>
<input type="text" name="postTitle" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
</div>
<div>
<label class="form-label" for="textAreaExample">Post</label>
<textarea name="postBody" id="textAreaExample" cols="150" rows="10" class="form-control"></textarea>
</div>
<button type="submit" name="button" class="btn btn-primary" class="mt-4"
style="margin-top: 1rem;">Publish</button>
</form
I am using nodejs to get catch the post request and logging it
在 app.js 中 这里我正在记录发送到服务器的请求
app.post("/compose", function(req, res){
const input = req.body;
console.log(input);
});
问题
Server started on port 3000
{ postTitle: 'dsfds', button: '' }
But only the postTitle thing is getting logged. Why is that?
【问题讨论】: