我有以下代码,它们从猫鼬数据库中获取图像 然后,我想使用标签在车把模板中显示图像。
app.get('/p',(req,res)=>{
//the image id in the mongoose
let id=Object("5d76d6af1c7cce2ee0f5b111");
//find the image given the id above
dbCollection.findOne({_id:Object(id)},(err,result)=>{
if(err){
console.log("Can not display the image" +err);
}
//gets the buffer of the image
let buff = result.img.buffer;
//converts the buffer into base64
let imgSrc = `data:${result.mimiType};base64,`+ buff.toString('base64');
res.render('databasefiles',{imgSrc:imgSrc });
})
});
this is my "databasefiles" handlebars I omitted the tags in here:
div class="myForm"
img src="{{imgSrc}}" alt=""
/div
enter code here
Nothing shows up when I open the handbars template,
Can someone please help me?