在以下代码中,我根据用户请求显示以下 HTML 文件。我还想在我的 app.js 文件中访问我的 app.post() 函数中的俱乐部名称和类型数据值。
<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
</head>
<body>
<% include templates/adminheader.ejs %>
<h1>Respond to Club Requests</h1>
<form name="clubform" method="post">
<% for (var i in clubreq){%>
Club Name:<%= clubreq[i].clubname %><br><br>//I want to access this variable in my app.post() function
Club Type:<%= clubreq[i].type %><br><br>
<input type="submit" value="accept"/><br><br><hr>
<%} %>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在app.js里面。在这里,我根据用户请求呈现 HTML 文件
app.get('/clubreq', function(req, res, next){
res.render('clubreq', {
title: 'Club Requests',
"clubreq" : docs
}); …Run Code Online (Sandbox Code Playgroud)