Apollo-link: Unable to parse JSON

Created on 18 Jul 2019  路  1Comment  路  Source: apollographql/apollo-link

When I am sending JSON from my backend to my application, I am getting blobs instead of the JSON I am expecting. When I stringify the error I am getting, I get:

```{
"graphQLErrors": [

],
"networkError": {
"name": "ServerParseError",
"response": {
"type": "default",
"status": 200,
"ok": true,
"statusText": "OK",
"headers": {
"map": {
"content-type": "application/json"
}
},
"url": "http://xxxxxxx.ngrok.io/graphql",
"_bodyInit": {

  },
  "_bodyText": "[object Blob]",
  "bodyUsed": true
},
"statusCode": 200,
"bodyText": "[object Blob]"

},
"message": "Network error: Unexpected token o in JSON at position 1"
}

When I run these queries directly on the server everything works fine. When I copy the request  from the debugger and manually fetch it, and then manually translate it using `response.text()`, I get:

`[object Blob]`

As the query itself works fine, shouldn鈥檛 the response be JSON?

Edit: I just realized I forgot to add my packages and whatnot, my bad:
"apollo-client": "^2.6.3",
"apollo-link": "^1.2.12",
"apollo-link-error": "^1.1.11",
"apollo-link-http": "^1.5.15",
"react-apollo": "^2.5.8",
"react-native": "^0.60.0",

```

Edit 2: Turns out this is related to whatwg-fetch being removed from React-Native 0.60 (see https://github.com/facebook/react-native/issues/25701)

Most helpful comment

In my case the error happens when the 'Network Inspect' of react native debugger is activated, as stated here: https://github.com/facebook/react-native/issues/25701#issuecomment-516596163

>All comments

In my case the error happens when the 'Network Inspect' of react native debugger is activated, as stated here: https://github.com/facebook/react-native/issues/25701#issuecomment-516596163

Was this page helpful?
0 / 5 - 0 ratings