-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[60.3] fetch issue [unable to parse json, unexpected token in json at position 1] #25701
Comments
This seems rather major, with basic |
you can somehow disable blob support in your project, because in |
Experiencing the same problem in 0.60.4 /cc @lklepner |
just updated to RN 0.60.4, I can confirm that I receive a blob when I used to receive a stringified json before. Fetch is unusable in its current state, thus making RN 0.60.4 unusable aswell. I will wait for a fix |
Same issue for me on RN 0.60.4 as well. Did not find any viable solution yet. |
I tried the |
I encountered the same problem in my project. For some reason, I managed to fix this (and I still cannot explain what happened) by downgrading some dependencies and clean build the app again. Here's the dependencies I changed: I don't exactly know which one fixed my problem, but it works for me now. Hope this helps whoever is struggling with this problem. My |
I am getting just this warning |
We have posted a reproducible test scenario here: react-native-async-storage/async-storage#174 We are not entirely sure if this is something that has to be fixed on the Hoping for some insightful feedback. |
For us, it is an issue with 'Network Inspect' in the debugger: jhen0409/react-native-debugger#365 Disabling that fixes this issue. |
@kennym That's a workaround at best, and it definitely doesn't fix this issue. |
@kbrandwijk Have you been able to find a fix? |
Anyone had any success here? |
@RageBill states this works. I haven't tried it yet, as I don't consider downgrading packages being a fix at all. If you have no other choice and absolutely have to use RN 0.60, you may give it a shot. |
No, just no. This is a breaking issue, and should be treated as such. This has been going on for almost a month now, I guess everyone just knows you have no way out once you're heavily invested in using RN... |
Was having the same issue (in Andorid release version), in my case, I fixed it by adding hope it helps ! |
XHR returning a Blob is not the issue. It's the fact that the check for whether or not the response is a |
I found a workaround by disabling Blob support in fetch: at the top of the files edit the support variable: with: |
This is absolutely not a workaround, most especially if you need to work with blobs at some point in your application. |
I totally agree. If you are going to patch |
sadly 0.60.5 did not fix this for me |
"react": "16.8.3", app fetch then Enable Network Inspect it seemed to work fine for me |
I have the same problem on rn 0.61.2 when I send a cookie with my fetch call. The call only works when I have RN debugger open and have global.blob set to null. |
I fixed this by using this code in componentDidMount in my app.js before I do any calls. It does seem that this is a dependancy issue (I think). When I commented the line of code that @YanYuanFE mentioned a few comments prior. All of my calls work as intended. |
@SergueyPutilin Thanks! This resolves the issue for me. |
@SergueyPutilin I had the same issue after upgrading to RN0.61. I literally have no clue whatsoever of what happened, but I installed axios as a dependency, tested and still got the same issue. I removed it from my package.json, uninstalled it and everything went perfectly fine after that. Any reinstallation of node_modules after that went perfectly fine and the problem disappeared. I really don't know, but, it works.... |
exactly this. Whenever i run the debugger, everything is working fine. When i try to run it without debugger my app just freezes while running the fetch. |
the same problem |
It seems to be the problem of reaction-native-debugger. If open debugger mode with reaction-native-debugger, and add Just remove this line: GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest |
In react-native body.constructor.name == 'Blob' gives true where as Blob.prototype.isPrototypeOf(body) gives false for blobs. I am able to fix it as
Add this condition to https://github.com/github/fetch/blob/7232090c04e1ddefb806910bbd0a756bc8aac2f0/fetch.js#L229 |
jhen0409/react-native-debugger#365 (comment) I had the exact issue, and i found a solution in the comment that i've linked. my react-native-debugger was on a pretty old version, and upgrading it to the newest version solved the issue. without the debugger running at all, i was getting network errors. with the debugger running, i was getting the parsing error. now i can make fetch calls with the debugger running and it works as intended. no other workarounds are needed. |
I solved my problem by adding param 'encoding'.
Before do this, you can check if response.text() is undefined, |
Any update ? |
|
See next comment |
Sorry about that ping. So, apparently, if you're using RN Debugger that's older than 0.11 and RN that's 0.61+, then you'll need to upgrade your RN Debugger. See here about compatibility: https://github.com/jhen0409/react-native-debugger#notice-react-native-compatibility Then there is no need to add any of the mentioned hacks to your codebase. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Can this issue be closed @MasoudAlali ? |
This helped but typescript is really unhappy with this. https://github.com/jhen0409/react-native-debugger/issues/382#issuecomment-646874107 |
This helped us on RN 0.66.1. Can't believe this is still an issue 😕 |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
React Native version:
0.60.3
Steps To Reproduce
there will be error like this:
unexpected token o in json at position 1
and I investigated for issue and it happens because in whatwg-fetch library
in line 492
support.blob
will be true and the response from xhr will be Blobso in fetch
response.json()
will fail because response is Blob not stringified jsonthere are some hotfixes, but I don't know exact solution for this
The text was updated successfully, but these errors were encountered: