response.json() hangs when chrome debugging
Problem
When using fetch to make a get to an external api, and if debugging in chrome is active, then it never reaches the second "then" until there is an interaction with the UI, such as a tap on the screen, but if debugging is turned off then this problem goes away. [code block] Using React Native 0.22 Only occurs on Android (both Genymotion and on device (5.0)) Using a Mac
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: response.json() hangs when chrome debugging
Got same issue with `response.text()`, `response.json()` and `response.arrayBuffer()`, but `response.blob()` seems to work fine. Versions are: [code block] Quick workaround is to add empty timeout execution: [code block]
Trust Score
6 verifications
- 1
Got same issue with `response.text()`, `response.json()` and `response.arrayBuff
Got same issue with `response.text()`, `response.json()` and `response.arrayBuffer()`, but `response.blob()` seems to work fine. Versions are:
textreact-native-cli: 0.2.0 react-native: 0.22.2 Android 5.1.1 ``` Quick workaround is to add empty timeout execution: ``` javascript fetch('http://example.com') .then(response => { setTimeout(() => null, 0); return response.text(); }) .then(response => { console.log(response); }); - 2
Quick workaround is to add empty timeout execution:
Quick workaround is to add empty timeout execution:
Validation
Resolved in facebook/react-native GitHub issue #6679. Community reactions: 24 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep