Javascript 如何从Express/Node.JS中的帖子返回网页?

Javascript 如何从Express/Node.JS中的帖子返回网页?,javascript,node.js,express,Javascript,Node.js,Express,如果我的网站中的一个表单正在发送帖子,而我是要处理的数据,然后将其重定向回“/”,我将如何处理 我现在的代码是 app.post('/contact', function(req, res) { console.log(req.body.Name) console.log(req.body.Email) console.log(req.body.TextArea) res.end(???) }) 这会准确地输出给定的变量,但我无法在线找到有关如何返回网页或重定向

如果我的网站中的一个表单正在发送帖子,而我是要处理的数据,然后将其重定向回“/”,我将如何处理

我现在的代码是

app.post('/contact', function(req, res) {
    console.log(req.body.Name)
    console.log(req.body.Email)
    console.log(req.body.TextArea)
    res.end(???)
})
这会准确地输出给定的变量,但我无法在线找到有关如何返回网页或重定向到其他网页的任何信息。

您可以使用res.redirect()

我的错误,http.get/request属于节点,而不是express。在节点中重新定位到页面的方法不是偶数.get(),而是.setHeader('/link'),res.end()是必需的

res.redirect('/');
就这么简单。

res.end()到底做了什么,我希望它能够自动调用?