react native Fetch Network request failed on android

react-native fetch not working on android
network request failed react-native expo
network request failed meaning
react-native network error axios
fetch failed android
react native fetch localhost
typeerror: network request failed react-native image upload
typeerror: failed to fetch react native

I'm trying to receive some simple json from mocky.

React native fetch function:

getMemberDomainList = async (name) => {
  try {
    let response = await fetch('https://5c9cc9ed3be4e30014a7d287.mockapi.io/api/domain', {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
      },
    });
    let responseJson = await response.json();
    return responseJson;
  } catch (error) {
    console.error(error);
  }
}

I have tested the address in chrome on windows, it returns the expected mock data. But when the function is called on my android phone I get this error

Error from remote debugger

...\node_modules\react-native\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:2348 TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (...\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:4337)
    at XMLHttpRequest.dispatchEvent (...\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:10760)
    at XMLHttpRequest.setReadyState (...\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:10511)
    at XMLHttpRequest.__didCompleteResponse (...\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:10343)
    at ...\Libraries\Renderer\oss\ReactNativeRenderer-dev.js:10449
    at RCTDeviceEventEmitter.emit (...\Libraries\Components\DrawerAndroid\DrawerLayoutAndroid.android.js:11)
    at MessageQueue.__callFunction (...\Libraries\ART\ReactNativeART.js:362)
    at blob:http://localhost:8081/79251787-d190-4650-8040-23d091c08738:2334
    at MessageQueue.__guard (...\Libraries\ART\ReactNativeART.js:312)
    at MessageQueue.callFunctionReturnFlushedQueue (...\Libraries\ART\ReactNativeART.js:139)

I'm also running a WebView in my app, which is pointing to a web url, it loads perfectly so I am sure that the phone has internet permission and access etc.

In the latest android versions http requests are not allowed by default. Take a look at this post for further information about allowing http request: How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

Fetch request throwing "Network Request Failed" error across host , Hi, I have written react native app which is working fine for IOS but while testing on google android simulator, it throws an error: "Network  React-Native fetch, Network request failed. On android #10404. Closed Clcll opened this issue Oct 15, 2016 · 78 comments Network request failed. On Android btw.

Can't get mockapi.io to work. But the error is not persistent when using services such as:

https://jsonplaceholder.typicode.com/todos/1

Might not be an android or react native related problem after all. Also had issues with mockapi.io in postman, though it works fine in chrome.

React-Native fetch, Network request failed. On android · Issue , My requests using axios are also failing: axios.get(`http://localhost:5000/posts`) .​then(response => { console.log(response) }) .catch(error  @cultofdev this is not a react-native bug, it's just the version of Android react-native is using Copy link Quote reply NSR88 commented Jun 10, 2020

If you are using emulator then check whether internet is working or not in this emulation using browser. If not check this: Android emulator not able to access the internet

I have also face this problem in emulator but when I generate a release app and install in a real device(andoid 9) then it works fine.

React-Native Network request failed on Android Emulator API 16-19 , areeb111 changed the title React-Native Fetch Network Request Failed on Android API 17 React-Native Network request failed on Android  ThemesPodcastArticlesPremium. React-native fetch throws “Network request failed” error on Android Devices with backend in remote server. JavaScript. android. masihfathi. August 16, 2017, 9

Please check backend response status.

If backend is sending contents using 205 status - 205 RESET CONTENT

Android system recognize it as an error - HTTP 205 had non-zero Content-Length: 25.

You can check the status code on postman. So, in this case, the error should be fixed on backend. It should send contents with 200 status code.

TypeError: Network request failed On Android · Issue #25244 , Hi Everyone, I found this problem on my React-Native Android App. When I using a fetch to communicate with a working api, this type of error is  I'm trying to call a simple REST service with fetch api in React Native. I'm running the app on Android. When I call await response.json() I get Unexpected token in JSON at position 0 , I tried also with await response.text(), and I get this text a

React-Native fetch Network request failed on android · Issue #20976 , Environment React Native Environment Info: System: OS: macOS High Sierra 10.13.4 CPU: x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz  Many mobile apps need to load resources from a remote URL. You may want to make a POST request to a REST API, or you may need to fetch a chunk of static content from another server. Using Fetch. React Native provides the Fetch API for your networking needs. Fetch will seem familiar if you have used XMLHttpRequest or other

React Native Fetch Remote Http request throws Network Request , res.json()) .then(res => { this.setState( { loading: false, error: res.error || null, data1: res }… React Native Fetch Remote Http request throws Network Request Failed (On Android Device) · Help: Expo Client · dhinesh. How do I “shake” an Android device within the Android emulator to bring up the dev menu to debug my React Native app ; React Native: fetch request failed with error-TypeError: Network request failed(…) Authentication with React Native and API backend

React-native fetch throws “Network request failed” error on Android , i used react native for mobile development and i used node js as a backend in a remote server(not localhost) with  To Make a React Native App. Getting started with React Native will help you to know more about the way you can make a React Native project. We are going to use react-native init to make our React Native App. Assuming that you have node installed, you can use npm to install the react-native-cli command line utility.

Comments
  • it could be because of http ... https is needed
  • in your remote debugger ... what did this console.error(error); print ?
  • remote debugger not workin unfortunately. But good point on the https, will try another mock service and see if that resolves it
  • switching to a https mock api seemed to make a difference, at least the stack trace looks a bit different. Same error though "network request failed"
  • Have you tried to exec the same api request using axios ?
  • Yes dev/prod build can have effect on things such as internet access or which protocols are allowed. In my case I was able to fetch against jsonplaceholder.typicode.com just fine ruling out the idea that I wasn't able to connect to the internet on the emulator.