title: Display image from encoded base64 on pug (jade) using node.js
body: <p>How to decode this data (I'm not sure if what type is this) and display the image. I'm using pug as template engine.</p>
  
  <p>Here is the data that I need to display as an image:</p>
  
  <blockquote>
    <p>/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQ ...and so on</p>
  </blockquote>
  
  <p>I tried this code in my node.js but it doesn't work</p>
  
  <pre><code>var img = Buffer.from(image).toString('base64');
  </code></pre>
  
  <p>The variable image is from this response:
  <a href="https://i.stack.imgur.com/oZaZw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oZaZw.png" alt="response"></a></p>
  
  <p>While this code is for passing data to .pug file</p>
  
  <pre><code>res.render('getsurveyemployeeimg', {
     surveyId: results[0].surveyId,
     empNo: results[0].empNo,
     empName: employee.result.fullnameEn,
     empImg: img,
     date: created,
     answers: results
  });
  </code></pre>
  
  <p>.pug file</p>
  
  <pre><code>img(src="data:image/jpg;base64,#{empImg}")
  </code></pre>
  
  <p>I always keep on getting broken image icon as an output</p>