HTTP Response is gibberish in browser but as expected in cURL or node.js

Viewed 482

I'm creating an HTTP request using axios (also tried with fetch) and the response I get is total gibberish. The weird part is that the same request using axios in Node.js or cURL results with the expected JSON. I suspect it's something related to the encoding but I'm not sure.

Here is how the request looks in axios:

axios({
"method":"GET",
"url":"THE_URL",
"headers":{
"useQueryString":true
},"params":{
"api-version":"3.0"
}
})
.then((response)=>{
  console.log(response)
})
.catch((error)=>{
  console.log(error)
})

And the response of the above request:

��\]oG�+��� o�
1�sc'�Պ��Ly�<=�Cu�XB�AB�C�K���Ɛl�_h�ȃ���?ټ����H�x��VW5LWO�֊b�j�3�ު�U}�n]�(�]yı?�0�&��6����7AI��y�G�����H(o�<:x�� �N�8)$���_}�����;����|D@=+ /�þUB� ;���n�z�Y{���}i{����J
�!�KJ��{ٽ��evo��"1���qm��q��N����mR@%i
�!Y2M�ycV�BC�q��n~�_���$h@��-W�����#�ȸ��`   ��L������܂�؂H�q%    ܺ��������[�[O�J�����V���E(t�hMi���6�K�z�c]�Q��#��H9�|SW����1A�(�U�G}�*&��Ej�v�P�.�'�Bp�*a88J�-�<�l�GD
%%�cTa�'��%���?�(�t�8�f؃i�p�-,��l��\J2����O%yv��|�3����B��ʰ�F�]�54�Y�ּ̚��]�ӡ�á��Ghy<I`8<G   �C;�(�OE"���V䓨��?�%E؅vѱ�j�GO$<���
��΢��l�p-̃��>8�C�����!? Gߧ���J�{;s�����.�-��T�8:�*���ZE`v�q���8pʡ^S�#�E�"�-H�mT�W•�le���~�ܖ(H�P,��7o��ɣ�|�&a}�=C���+��¤�`�� ^�G��{�`ϯ���I9V�WW��f���Ip�MN܆<�vL�C�pprsz�U�Y�m���R�-�������`k�l���Cˊ��ȚK���5g��&�H&�)ڐ��8O1��Y��'��SS0�T�40��0x{��$��%E���Ɔ��=y�:���AIZ����E"M�n�����}L7�=D����ޒ.0(�l5a��ۓ|3.u���_bs���6���K}^�N8�6W�U��(-�H��6a~� �r˞�I�ZE�'褞_��08p���D�4�?�Xp;�K��5�P*���y�   ��Ϝ�2����;��    #�g��ZQ۳�W���ތ��I�N��SGҦ;h���
ū�k%�X�~����j�*�@UG�[E =4Ԡ�Lǃ���N,��qi��y��P��qV�m��.�2��υ���.���u�ŝ���5K�$q�؃s~U�%���&[\d����5���Dw�c��CYbXj��li�-O���S")C�2������5�Zw$�UNv�q��%'�+���r��"�;���    ��"!��c|ё������ /x*���0�ӊbd�m�L+�����z�LT/�]�p�^����m�����K����s@��dIb�&|N��ٽ������W�]�[�/�-�U�
����L����������7|8�����'��(ɔx�`�C}�^��C�EE��������8�n}�_������פ!r�|h$H��2�p��j�"%��Ko��y�P��)��T�(  ;�0���8六�s��<n�.�b����ă$�_�2k'$D����"��w^]uU �X}���>ҥ��i=yV7u����.�j�!y)��?h]n�/3��IX�t�ʸ��s%���4��F����s���x�d���*�)!���[;�t����S�R��6t�F
R��a\G���_6*)^�:�X� k�u�3A6!�G���\aw�b�;��r����R���ʜeT�Χ5�͖����W�__���ʪ�����D)�����^JT���v���y��|m�nΑ�T���ը�jR���}��\�>�����“}��6v]�k�W��Ӵ��&��հ��L���rKN}�e�U�"�оϼ�þ����NUx�C��l��oޗ����͟�U�++�����y��}��:Y`�a �(y��}6s�,���2�*s4���Z����l����gCH:Ak��VXk>���:"Njj�.k-��M�Zc�T�!G�ʏ�G5�����.���G}���7_�iM'���ꤰ�l�o~�}���\�S-"-�"8kD�.$�K��:ۧ��zE�����wO���ݯ�m�A�����r'gI��=�����Ax�{��.Q�C�C���q|��f4�匸!i����8ɞ���Љv3
u�R�y�ސ���f�hU�w�������(Ͳ�t5�ף�"������Pȣ��t|�t�:$����5du!k���e�A2�A�÷H�%<����CZ�n@t�a�/
^�:B,hL�p�Z�(K�QL!x��*������"�  ��=�$�x"�u_罧D%"*�d)6��&���P�0<2���<�_2����=�wb
Rd��hHQ��V���=KEOL!���ߖwI&�1��"&��8�"k%KDc  �d*h�9�#K}FDQ�=���p�_3y�,SS�ʐ�b#Ⰵ���^$f"j��f��ܕ1��I��"*���1�W�!D$�$kb&q-�s�?��~��{/�i�"C����C��"O|��    �B��?�3�%PX�s�1��XꟐ�}at�|P>��4��Glu�}/ԭy7���WFoF�ne�!5Z�����4p���   9�������7�  vY��#z�L�y�3"J�v3rr]�`HR�;)ҽ����7E��}]�9��l0$I�3z�.V0$E��Cr�\�`F�����^RaF��u����J3*��0�'��fD帱���`R�ߋ,�ԼÐ��6���w��!Mz�y��+Bi���ْ�&����C⠯2$IMh��%f���N/^�
;���KX

And the response headers as well:

HTTP/1.1 200 OK
access-control-allow-credentials: true
access-control-allow-origin: https://MY_ORIGIN.com
Content-Type: application/json
Date: Wed, 16 Sep 2020 07:37:00 GMT
Server: MY_SERVER_VERSION
Content-Length: 5204
Connection: keep-alive
0 Answers
Related