title: How to convert/decode base64 from XHR request response string
body: <p>I keep facing a problem converting XHR request response properly. I've read couple of solutions on Stackoverflow and on some other platforms but couldn't success to convert string to dataURL.</p>
  
  <p>I've tried to convert string to through <code>atob()</code> and <code>btoa()</code> methods mention on <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding" rel="nofollow noreferrer">MDN</a> and this <a href="https://stackoverflow.com/a/26603875">Stackoverflow</a> post.
  + I've keep dive much to find a solution within lost of different methods but non of them took me aim.</p>
  
  <p>How can I convert this response below to a dataURL properly to be able set the URL as <code>image</code> <code>src</code>?</p>
  
  <p>XHR Request Response:</p>
  
  <pre><code>    "�PNG
  
  
  IHDR��  m"H3PLTE���������������������������������������������������?�U�iIDATx�흋�� Eۈ�Z����R�[���BB�]�_�Y�� x��a�a�a�a�a�a�a�a��-��nFI]]�}_x�}�����$ʆ�h�s�_4M_w�WI��*��.o���"��~۔�C^uڟ�P5W�'�[��(��}�=)���U�����Z�J#U��G�'�8G�߻ۓH�&gt;��E���G�&gt;݁K�ތ4l��C��
  v�xu���?�*R��^������ł�B[�Y׸kkY����=�
  
  l|H�s7Yp"���+6zV�cvSj+�
  �}�c�c݄Pކ
  ~�W�N֨(�3����0[QƄ�Q�)o�_R,�]J����G�b��?��M  9�  w*h��!=�%"�4������˔*a��
  
  ���6��w'��&gt;��el3�e�l����c�ݍ(U.p�Q2�э����#��BɺB�h�4Sh��I�
  �s��B���P735���(L�KU_�����s��v�]~�������6�+
  /��iD���    �����uԏf�ﳽ�}nA�1_7��t�
  +m�2W���P:�8�N�.Ԉ}�KQ�`�G0�P�Y�}�=A|�$� ��Xǭ�؅)w���&gt;����m�J�R�֖��~}�n�@�G��7�ͽ���d������58C��i�6|�&amp;�ۄ?pIl:P�l   *FE�
  q��wj��v��6�.�BQ�߁�����GBm�{�(�
  �!f�k�Df*?}�+�N��"u��V,N��.eҚj��r�t��А�r��&gt;)��*a��J����4�U���L��Z�/�ҵ���e=�;Qp����=x�[5=N��:8O}��k�?�Rr"�ma��tڱQ�I���R���=ܣU�MI�3Y�6\�~�v�.yJ�)��q�&amp;���/�_�R�A-����{Ҡ�$��RNx%�}'�D�Tm�d9��}�n��~�kz��Ӝ���K� b��] L|�iqo3�O��p��l��  'd�$�D�!:e��F=����'�"7g�F=b��7+Qܤ֩n�_"��c�����w$~`�V�"��I�{�&amp;R̰G�O�|��%�    ��/�L���&gt;�  �wb�S����- �3O����*J��7�͈�
  �m�JL�Fdҗ��0��&gt;���0��&lt;����0�I!�33,y
  d&gt;3Ò�&lt;y��)�'�pxS�E����;�����)�2�p��Dt��P�*�����Y�.�܈�
  ��D�5�Y�Ld����l��cb�lQ�|4�DED�͒�n
  ^3��&amp;F!|��D��?�'��q
  G�jN�h�\�   2ODVu�d���'���LLs_�ۏ�&gt;CV�   �gQ�{���e�  
  ���2��*�Q�&gt;|y��fg�M9a��E�IEND�B`�"
  </code></pre>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I've succeed to render image through  this post @
  <a href="https://stackoverflow.com/a/8022521/7163711">https://stackoverflow.com/a/8022521/7163711</a> </p>