[Only Android] fetch Error : [Network request failed]
See original GitHub issueDescription
—My Code—
const reverseGeocoding = async (location: Location) => {
const params = new URLSearchParams({
"orders": `admcode`,
"output": "json",
"coords": `${location.longitude},${location.latitude}`
}).toString()
const resultBare = await fetch(`${Config.REVERSE_GEOCODING_URL}?${params}`, {
method: "GET",
headers: {
"X-NCP-APIGW-API-KEY-ID": `${Config.NCP_AI_CLIENT_ID}`,
"X-NCP-APIGW-API-KEY": `${Config.NCP_AI_CLIENT_SECRET}`,
}
})
const jsonResult = await resultBare.json()
console.log(JSON.stringify(jsonResult))
return jsonResult;
}
—Not working solution—
- android:usesCleartextTraffic=“true”
- commenting out line number 43 in this file android/app/src/debug/java/com/**/ReactNativeFlipper.java
38 NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39 NetworkingModule.setCustomClientBuilder(
40 new NetworkingModule.CustomClientBuilder() {
41 @Override
42 public void apply(OkHttpClient.Builder builder) {
43 // builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44 }
45 });
46 client.addPlugin(networkFlipperPlugin);
27 # Version of flipper SDK to use with React Native
28 FLIPPER_VERSION=0.39.0 // edit this manually
its too old solution my code already 0.99.0
—Error—
Possible Unhandled Promise Rejection (id: 0):
TypeError: Network request failed
http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:25357:33
http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:29572:26
_callTimer@http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:29492:17
callTimers@http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:29693:19
__callFunction@http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:3056:36
http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:2780:31
__guard@http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:3007:15
callFunctionReturnFlushedQueue@http://192.168.1.13:8081/index.bundle?platform=android&dev=true&minify=false&app={package.my.project}&modulesOnly=false&runModule=true:2779:21
callFunctionReturnFlushedQueue@[native code]
fetch not working only android emulators , physical device too
Version
0.66.4
Output of npx react-native info
System: OS: macOS 11.1 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Memory: 3.60 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.3.1 - /usr/local/bin/node Yarn: Not Found npm: 8.3.1 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7351085 Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild Languages: Java: 11.0.9.1 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.4 => 0.66.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
just using fetch, axios etc… any networking tools
Snack, code example, screenshot, or link to a repository
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:21 (1 by maintainers)
Top GitHub Comments
For me, I was able to fix this by adding a mime-type of the file to the upload (wasn’t required previously or on iOS):
Hope that helps someone
Any Update? Facing the Same Issue