-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
fetch SyntaxError: Unexpected token in JSON at position 0 #29267
Comments
|
|
|
from snack, i found out that the issue is in android... |
Does anyone even watched this issue? |
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. |
This issue was closed because it has been stalled for 7 days with no activity. |
Description
fetch response can not be parsed as json as it has a space character at first position. this character: ( );
also if return response as Text and try to JSON.parse, get same error!
using fetch on browser on same url doesn't have that issue so it means a bug in fetch library!
also tried XMLhttpRequest and same error!
How i solved problem:
JSON.parse(response.substring(1))
//---> works! 😐 (response is string of object)snack demo:
https://snack.expo.io/05cxVMQnX
React Native info:
System:
OS: Windows 10 10.0.17134
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 7.46 GB / 15.89 GB
Binaries:
Node: 13.12.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.0, 28.0.3
System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6308749
Languages:
Java: 1.8.0_221 - C:\Program Files\Java\jdk1.8.0_221\bin\javac.EXE
Python: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: ^0.63.0 => 0.63.0
The text was updated successfully, but these errors were encountered: