android - React Native fetch, unexpected token -


i'm trying call simple rest service fetch api in react native. i'm running app on android.

when call await response.json()

unexpected token � in json @ position 0

, tried await response.text(), , text result:

��mn�0��b�[c�bn�u��?@�+�blr�Ҍbr.� �����h�ծ�͛�#?>�g���t�%{���z��؄u�>fs0]����h��'&��u�z}��y�z��2����i�d�g�>����r����6ll{j�j�7\���������d���l.���gٲxv�lf��g�%t�~�\z�u8e܀���ڭ�c��@[g�;�t�������{�*�9�)��a½ ���0�组v:ϒ���/�k��3�ݝ����w: c�^uv@�b�7�@�v �+wg��@yl�|Ġ>q�=@�j}�3=��q�]Հup^e�0 ^d'Ա �^���b�.��2,м���g2��r<���_rpv:!��<��^>�����{�e�#7m���na�;n�������l�o�u��kw���r���

this code i'm using:

export function fetchmenu() {   return async(dispatch) => {     try {       dispatch(menurequest(true));       console.log(institucion.aplent);       var response = await fetch('http://<page_url>/api/moviles/personalizacion', {         compress: true,         headers: {           'aplentid' : institucion.aplent,           'accept-encoding' : 'gzip,deflate'         }       });       console.log(response);       if(!response.ok) throw error(response.statustext);       var data = await response.json();       console.log('data:', data);       dispatch(menusuccess(data));     }     catch(ex) {       console.log(ex);       dispatch(menufailure(ex));     }   }; } 

note: i've changed url security reasons, have correct url in code.

i've tried , without accept-encoding header, same result.

edit

if disable deflate compression inside rest api (on server) works ok, doesn't fetch support deflate compression?

add these headers fetch call ensure receive json:

 'content-type': 'application/json',   'accept': 'application/json', 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -