[iOS] Network request failed on device
See original GitHub issueI’m using RN 0.29.0 and Fetch to authenticate with a server and getting the Network request failed.
I was getting it on the Simulator but I saw there are many issues with Fetch and El Capitan iOS simulator such as this one.
Now I’m building for the device and getting the same error.
Obviously, when building for release I can’t see the error on Chrome but the code doesn’t work.
When using Chrome dev tools I see this:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:24332:8)
at XMLHttpRequest.dispatchEvent (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:9864:15)
at XMLHttpRequest.setReadyState (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25778:6)
at XMLHttpRequest.__didCompleteResponse (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25636:6)
at http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:25711:52
at RCTDeviceEventEmitter.emit (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:9095:23)
at MessageQueue.__callFunction (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7183:23)
at http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7087:8
at guard (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7035:1)
at MessageQueue.callFunctionReturnFlushedQueue (http://192.168.100.102.xip.io:8081/index.ios.bundle?platform=ios&dev=true&minify=false:7086:1)
This is the relevant code:
fetch(url, {
method: 'POST',
body: 'username='+username+'&password='+password,
headers: {
'Accept': 'application/json',
"Content-Type": "application/x-www-form-urlencoded",
}
}).then((response)=>{
...
},(error)=>{
console.log(error.message)
}).catch((error)=>{
console.log(error)
})
I thought maybe it was some configuration problem when preparing the files for production but the docs are outdated and do not correspond with the reality.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
React-native IOS: Network request failed - Stack Overflow
I'm testing a react native app (on OS X Yosemite in the xcode simulator v9.2 / xcode 7.2.1). I'm getting a Network request...
Read more >[TypeError: Network request failed] using fetch, iOS only issue ...
On IOS 13 it works fine. Did you solve it? My error looks like this. TypeError: Network request failed at fetch.umd.js:527 at JSTimers ......
Read more >iOS 16 network request failed on P… | Apple Developer Forums
Hi, We have developed a VPN app, we recently received feedback from some iOS 16 users that VPN connections cannot be established, We...
Read more >React-Native fetch, Network request failed. not using localhost
iOS : React-Native fetch, Network request failed. not using localhost [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] iOS ...
Read more >Expo React Native network request failed - YouTube
This video shows how to solve react native expo network request failed. if the this video helped leave a like and subscribe to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s not clear from your code but make sure that
urlis HTTPS, or turn off ATS the same way as any other iOS app in case that is the issue.checkout my answer it helped my freind also #10404