【发布时间】:2020-02-04 06:36:25
【问题描述】:
我正在寻求帮助。我正在使用 nodejs、mongoDB 和车把模板创建一个画廊应用程序来显示画廊。一切都很好,直到我在我的 mongoDB 中找到所有图像(存储为二进制数据)并尝试在我的车把模板中呈现。我正在尝试这个:
routes.js
router.get('/gallery', async (req, res) =>{
const pics = await Img.find();
console.log(pics); // No problems showing images as binary data and all fields in the Schema
res.render('images/gallery.hbs', {pics});
});
模板.hbs
{{#each pics}}
<div class="row">
<img src='????'>
</div>
{{/each}}
在哪里????是我的大问题,我不知道放在那里的代码是什么,或者我是否使用了正确的方法。 请帮忙。我是新人
【问题讨论】:
标签: node.js mongodb image binary handlebars.js