示例代码:
// index.pug
p #{polls}
// 端点
http://localhost:8080/api/polls
// 路由文件 (index.js):
在这里,我如何向 api 发出 get 请求,并在渲染 profile.pug 时将检索到的结果从 api(locals) 传递给 polls 变量
app.route('/profile')
.get(isLoggedIn, function (req, res) {
res.render('profile', {'polls': passvaluehere});
});
});