title: How to convert local image file to base64 in Angular?
body: <p>I have an image locally in a folder: assets/img/xyz.JPEG and I want to convert it to base64. Kindly provide the code necessary to do so in Angular 8</p>
  
  <p>I tried using file reader and btoa but didn't work.</p>
  
  <pre><code>var reader = new FileReader();
  var binaryString = reader.readAsDataURL('assets/img/xyz.JPEG');
  var image = btoa(binaryString);
  </code></pre>