0

I'm wondering why my node-express code is not working while making base64

post.image is mongodb buffer

to string

posts.map((post, i) => {
    post.image = 'data:image/jpeg;base64,' + new Buffer(post.image, 'base64')
})

posts.map((post, i) => {
    console.log(post.image)
})

it gives me buffer of result oㅅo

김성민
  • 27
  • 4
  • Possible duplicate of [How to do Base64 encoding in node.js?](https://stackoverflow.com/questions/6182315/how-to-do-base64-encoding-in-node-js) – Dan O May 10 '18 at 15:09
  • I tried with this post but failed It doesn't work – 김성민 May 10 '18 at 15:09
  • Failed in what way? It clearly shows how to convert a `Buffer` object to a base64 encoded string. – Cisco May 11 '18 at 10:40

1 Answers1

0

Solved.

mongoose schema was the problem

changing Buffer to Mixed fixed it

김성민
  • 27
  • 4