Javascript POST到Node.js服务器,导致长时间加载,导致ERR\u EMPTY\u响应

Javascript POST到Node.js服务器,导致长时间加载,导致ERR\u EMPTY\u响应,javascript,node.js,html,forms,post,Javascript,Node.js,Html,Forms,Post,我有一个简单的表单,将用户的输入发布到服务器。提交表单后,页面会长时间加载,导致ERR_EMPTY_响应。但是,我可以将表单的输入很好地记录到console.log中,以验证表单是否确实正在发布到服务器 以下是我的工作内容: <form method="post" action="/"> <input type="text" name="userZipcode" placeholder="Enter your zip code"> <button t

我有一个简单的表单,将用户的输入发布到服务器。提交表单后,页面会长时间加载,导致ERR_EMPTY_响应。但是,我可以将表单的输入很好地记录到console.log中,以验证表单是否确实正在发布到服务器

以下是我的工作内容:

<form method="post" action="/">
    <input type="text" name="userZipcode" placeholder="Enter your zip code">
    <button type="submit">ENTER</button>
</form>
注意:fetch请求最终会将数据从API响应传递到我的EJS页面,但目前它只会呈现索引页面


按照上面的格式,我从终端的输入字段中获得了一个带有zipcode的console.log。然而,之后页面只是加载,直到它在上面提到的错误中结束。我知道我错过了一些重要的东西,但我不知道那是什么

在发帖路线中,你必须做出回应。您的代码没有响应请求。这会导致ERR_EMPTY_响应

app.post('/', function(req, res) {
    let zipcode = req.body.userZipcode;
    console.log('Your location is: ' + zipcode);
    res.end("your response");
});

在发帖路线中,你必须做出回应。您的代码没有响应请求。这会导致ERR_EMPTY_响应

app.post('/', function(req, res) {
    let zipcode = req.body.userZipcode;
    console.log('Your location is: ' + zipcode);
    res.end("your response");
});