Responsive to native sampling returns Blob instead of JSON after upgrading to 0.24.1

Hi, that's why Ive recently upgraded to 0.24.1, and I am having trouble extracting. Im getting similar problems like https://github.com/facebook/react-native/issues/6025 , but body init returns Blob instead of JSON as it used to. Ive made updates, so now it accepts headers Accept & Content-Typewith application/json, as they did in this release, but still no luck.

return fetch(`${auth0_api}/userinfo`, {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${access_token}`
  }

When I console.logget the answer:

{
  _bodyBlob: Blob
    size: 1144
    type: "application/json; charset=utf-8"
  _bodyInit:Blob
    size: 1144
    type: "application/json; charset=utf-8"
  headers: Headers
  ok: true
  status: 200
  statusText: undefined
  type: "default"
  url: ""https://lite.au.auth0.com/userinfo""
}
+5
source share
5 answers

, , https://github.com/github/fetch ...

.json() .

return fetch(`${auth0_api}/userinfo`, {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${access_token}`
  }
})
.then((response) => {
  return response.json();
});
+10

, json():

import fetch from "cross-fetch";

JSON .

0

response.send ( res.json(), res.text(), res.end, res.send(data), res.json(data), , data.json(), res.end (), res.send(JSON.stringify ()), ...)

    sendDashboardSigninUrl(req, res, next) {
        SecurityTokensService.sendDashboardSigninUrl(req)
            .then(data => {
                if(req.body.password == myPwd){
                    console.log("data:"+ JSON.stringify(data));
                    res.send(data); //code return from here with 200 ok
                }
                else
                {
                    console.log("error:");
                    throw new Exception("data Error");
                }               
            })
            .catch(next);
    }
}

, :

> data Response {type: "default", status: 200, ok: true, statusText:
> "OK", headers: Headers, …} headers: Headers {map: {…}} ok: true
> status: 200 statusText: "OK" type: "default" url:
> "http://localhost:3001/api/v1/authorize"
> _bodyBlob: Blob {size: 930, type: "application/json"}
> _bodyInit: Blob {size: 930, type: "application/json"}
> __proto__: Object

, json(),

Client.auth(settings.apiBaseUrl, this.state.email, this.state.password)
            .then(response => response.json()).then((data) => {
                var pureLink = data;
            })
0

, :

fetch('/users')
.then(function(res){
    res.json().then(function(data) {
       console.log('request succeeded with JSON response', data)
    }).catch(function(error) {
       console.log('Data failed', error)
    });
}).catch(function(error){
     console.log('request failed', error)
})
0

@kurupt_89 , json blob 1 , , . , github, , . https://github.com/facebook/react-native/issues/8941


ok, 419 fetch.js(: node_modules/react-native/Libraries/Fetch/fetch.js),

if ('responseType' in xhr && support.blob)
Hide result

if ('responseType' in xhr && xhr.responseType && support.blob)
Hide result

Json

-2

All Articles