Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Unable to parse JSON #1115

Open
shoulderface opened this issue Jul 18, 2019 · 1 comment
Open

Unable to parse JSON #1115

shoulderface opened this issue Jul 18, 2019 · 1 comment

Comments

@shoulderface
Copy link

shoulderface commented Jul 18, 2019

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’t 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 facebook/react-native#25701)

@pleportz
Copy link

In my case the error happens when the 'Network Inspect' of react native debugger is activated, as stated here: facebook/react-native#25701 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants