Villar
Villar

Reputation: 133

Fetch return blob instead of text after 0.59 RN update

I update my RN app from 0.58.3 version to 0.59.4 and instead of bodyText server return bodyBlob now

I tried to use response.json() func but it doesn't help

fetch(`http://someserver `, {
      method: 'POST',
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'Accept-Language': 'ru,en;q=0.9',
      },
       body: '{"login":"root","password":"root"}'
    })
      .then((response) => {
        console.log(response.json());
      });

response i get is like this:

{
    "type": "default",
    "status": 200,
    "ok": true,
    "headers": {
        "map": {
            "x-xss-protection": "1",
            "set-cookie": "jwt=eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyLWNvZGUiOiJyb290LXVzZXIiLCJleHAiOjE1NTU0MjY0Mjl9.UaHzsIil8t9HtgrBF8JN0c2W-eIIkDEmb6GvO9Do0-A;Expires=Tue, 16 Apr 2019 14:53:49 +0000;Path=/;HttpOnly;SameSite=Strict",
            "connection": "keep-alive",
            "content-length": "360",
            "content-type": "application/json;charset=utf-8",
            "date": "Tue, 16 Apr 2019 13:53:49 GMT",
            "server": "nginx/1.15.10"
        }
    },
    "url": "***",
    "_bodyInit": {
        "_data": {
            "size": 360,
            "offset": 0,
            "blobId": "3397402a-12dd-4dd9-8980-90924aeb416d"
        }
    },
    "_bodyBlob": {
        "_data": {
            "size": 360,
            "offset": 0,
            "blobId": "3397402a-12dd-4dd9-8980-90924aeb416d"
        }
    }
}

instead of normal bodyText i get bodyBlob

Upvotes: 1

Views: 648

Answers (1)

Onur Polattimur
Onur Polattimur

Reputation: 41

Sorry, I am late with the answer. I hope it will be helpful for others. Be careful, response.json() returns promise.

fetch(`http://someserver `, {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'Accept-Language': 'ru,en;q=0.9',
    },
    body: '{"login":"root","password":"root"}'
})
.then((response) => {
    response.json().then(res => {
        console.log(res);
    })
});

Upvotes: 1

Related Questions