title: Javascript error while downloading a file from REST api
body: <p>I have 2 application.
  A server made with spring boot and a client made with Vue2.js.</p>
  <p>I need to download a xlsx file.</p>
  <p>So in the server a use apache poi lib to create the file and then</p>
  <pre><code>ByteArrayInputStream in = excel.getWorkerReport(reportMap, Month.of(month));
  
          InputStreamResource file = new InputStreamResource(in);
          
          return ResponseEntity.ok()
                  .header(HttpHeaders.CONTENT_DISPOSITION, &quot;attachment; filename=export.xlsx&quot;)
                  .contentType(MediaType.parseMediaType(&quot;application/vnd.ms-excel&quot;)).body(file);
  </code></pre>
  <p>to send the file into the response.</p>
  <p>In the Vue2js client when i press the Export button i use Axios to hit the controller and download the file.</p>
  <pre><code>let response = await axios.get(url)
          console.log(response.data)
          var a = window.document.createElement('a');
          a.href = window.URL.createObjectURL(new Blob([response.data], { type: 'application/octet-stream' }));
           a.download = &quot;export.xlsx&quot;; //fName was the file name portion of the key what was passed in as part of the key value within params. 
  
          //  // Append anchor to body.
           document.body.appendChild(a)
           a.click();
  
          //  // Remove anchor from body
           document.body.removeChild(a)
  </code></pre>
  <p>The response.data is something like</p>
  <pre><code>PKN��R[Content_Types].xml�S�n�0����*6�PU�C���\{�X�%����]8�R�
  q�cfgfW�d�q�ZCB|��|�*�*h㻆},^�{Va�^K&lt;4�6�N�XQ�ǆ�9�!P��$��҆�d�c�D�j);��ѝP�g��E�M'O�ʕ����H7L�h���R���G��^�'�{��zސʮB��3�˙��h.�h�W�жF�j娄CQՠ똈���}ιL�U:D�����%އ����,�B���[�    �� ;˱� �{N��~��X�p�ykOL��kN�V��ܿBZ~����q�� �ar��{O�PKz��q;PKN��R_rels/.rels���j�0�_���8�`�Q��2�m��4[ILb��ږ���.[K
  �($}��v?�I�Q.���uӂ�h���x&gt;=��@��p�H&quot;�~�}�   �n����*&quot;�H�׺؁�����8�Z�^'�#��7m{��O�3���G�u�ܓ�'��y|a�����D�    ��l_EYȾ����vql3�ML�eh���*���\3�Y0���oJ׏�  :��^��}PK��z��IPKN��RdocProps/app.xmlM��
  �0D�~EȽ��ADҔ���A? ��6�lB�J?ߜ���0���ͯ�)�@��׍H6���V&gt;��$;�SC
  ;̢(�ra�g�l�&amp;�e��L!y�%��49��`_���4G���F��J��Wg
  �GS�b����
  ~�PK�|wؑ�PKN��RdocProps/core.xmlm��J�0F_�依4+RB�E�Aq�Ż��m��!�v}{ӺVP�|g��������5
  )J24Ҫ�t
  y8��d!
  ��h
  6�X�mk鸴��:�q��%�   \���1:d�Z�&quot;&amp;�/�k��w��|��4F�D0s��I��to~\J����eQ���������1+5MS1m.mT������|&gt;���I[��\zU�&lt;~���w:�H�(+sz����(���깆_���l}{�
  �1��]���\ß��OPK��PKN��Rxl/sharedStrings.xmle��JA��&gt;�0OvVA����M���m�
  �$�$[||�&quot;��/ߟ��_yrG�J½�^t�!�#&gt;�������/�ET57����[�f��W��~��~4+!�0b]HAnf/5�5����&quot;�tD�&lt;�����}�J)Zz��1X���?�'�KA�&quot;�Dr���F,n+�&quot;���ȫ(�k6���Vbp�ˍQ�?�К�oPKee�&amp;PKN��R
  xl/styles.xml���n�0��{�(���JS
  </code></pre>
  <p>and other characters
  But the excel file that is created cannot be opened for wrong extension or format.</p>
  <p>But if i use Postman, the response is the same and if i save it as a file, the file is perfect, so it looks to me that the server part is good but I have some problem in the JS client to really decode and create the file.</p>