【发布时间】:2018-06-11 05:01:46
【问题描述】:
在猫鼬从数据库中获取数据之前,任何人都可以帮助我在哪里生成问题视图。我已经使用 await 但它不等待响应。
router.get('/', async(req, res, next)=> {
try{
const products = await Product.find({});
res.render('shop/index', { title: 'Express',products });
}catch(e){
console.log(e);
}
});
【问题讨论】:
-
你是如何断定它没有等待响应的?
-
获取所有产品信息后需要视图渲染
-
在渲染之前尝试使用
console.log记录产品
标签: node.js mongodb express asynchronous mongoose