我正在使用Express& Ejs&身体解析器;服务器js:
app.post('/', function(req, res) {
if (!req.body) return res.sendStatus(400)
console.log(req.body)
});
我的Index.Ejs文件
<div class="container">
<fieldset>
<form action="/" method="post">
<input name="city" type="text" class="ghost-input" placeholder="Enter a City" required>
<input type="submit" class="ghost-button" value="Get Weather">
</form>
</fieldset>
</div>
我在控制台中收到此错误: -
Cannot set headers after they are sent to client