I just tried to add image as buffer to mongodb and tried to convert back to image. In ejs, it worked fine.
src="data:image/png;base64,<%=project.image1.toString('base64')%>"
This is the code i used in ejs.
But when i tried to append this to an element through pure js, it shows error
$('#two').prepend($('<img>',{id:'theImg2',src:`data:image/png;base64,${ selected[0].image2.data.toString('base64')}`}))
This is the code i used in pure js.

This is the object i consoled in js.
This is the error!
Thank you!

image2.datacoming from?