Skip to content
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

Closed
arasrezaei opened this issue Jul 2, 2020 · 7 comments
Closed

fetch SyntaxError: Unexpected token  in JSON at position 0 #29267

arasrezaei opened this issue Jul 2, 2020 · 7 comments
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. 🌐Networking Related to a networking API. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@arasrezaei
Copy link

arasrezaei commented Jul 2, 2020

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

@react-native-bot react-native-bot added the 🌐Networking Related to a networking API. label Jul 2, 2020
@chrisglein chrisglein added Needs: Author Feedback Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. and removed Needs: Triage 🔍 labels Jul 8, 2020
@github-actions
Copy link

github-actions bot commented Jul 8, 2020

⚠️ Missing Required Fields
ℹ️ It looks like your issue may be missing some necessary information. GitHub provides an example template whenever a new issue is created. Could you go back and make sure to fill out the template? You may edit this issue, or close it and open a new one.

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@github-actions
Copy link

github-actions bot commented Jul 8, 2020

⚠️ Missing Environment Information
ℹ️ Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.

@react-native-bot react-native-bot removed the Needs: Environment Info Please run `react-native info` and edit your issue with that command's output. label Jul 8, 2020
@arasrezaei
Copy link
Author

from snack, i found out that the issue is in android...
ios and web working well

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jul 12, 2020
@arasrezaei
Copy link
Author

Does anyone even watched this issue?
🤔🤔

@stale
Copy link

stale bot commented Dec 25, 2020

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 25, 2020
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Needs: Issue Template This issue does not make use of the Issue Template, and may be missing necessary information. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. 🌐Networking Related to a networking API. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants