我想确保我的应用程序在所有查询完成并且获得所有必要的数据后才调用res.render('pages / students ...)。但是,我完全不知道如何执行此操作,并且我无法将自己在网上看到的所有示例都应用到代码中。有人可以帮我吗? (我的路线中有两个con.query(...)。我只想在这两个con.query完全完成后才渲染('pages / students'...)。因此,我正在使用异步运行所有我的查询要完成。但是由于某种原因,我的页面不会加载事件。
.acc(
font-family: "Times New Roman", Times, serif;
font-style: normal;
font-weight: normal;
font-size: 30px;
line-height: normal;
color: #000000;
margin-left: auto;
margin-right: auto;
background-color:black;
text-align:center;
vertical-align: middle;
padding:20px 47px;
}
答案 0 :(得分:0)
两个选项:
app.get('/admin', function(req, res) {
...
con.query(sql, function(err, result) {
...
con.query(sql, values, function(err, result) {
events[date][currRecord.name] = {
...
};
// put it here
console.log(events);
res.render('pages/admin', {
events: events
});
});
}
});
});
或使用Promise
的{{1}}版本
mysql