3
votes

the below is my Fetch code:

return fetch('https://172.16.57.200:8080/cebip/financeProductList',{
        method: 'GET',
        headers: {
          'Accept': 'application/json',
          'Content-Type': 'application/json',
        }
      })
        .then((response) => response.json())
        .then((responseJson) => {
          alert("hi");
          console.log(responseJson);
        })
        .catch((error) => {
          alert("error");
          console.error(error);
        });

and i get the below error in android :

Network request failed - node_modules\whatwg-fetch\dist\fetch.umd.js:473:29 in xhr.onerror - node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent - node_modules\react-native\Libraries\Network\XMLHttpRequest.js:574:29 in setReadyState - node_modules\react-native\Libraries\Network\XMLHttpRequest.js:388:25 in __didCompleteResponse - node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0 - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard - node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0 * [native code]:null in callFunctionReturnFlushedQueue

3

3 Answers

1
votes

I changed the port of my own server to 19001 and it worked for me. If you are developing your own server maybe you should try this way. I hope it worked to you

0
votes

I have had a same error while using 'https' with the local IP,it could be resolved by simply removing the 's' eg:'http://172.16.57.200:8080/cebip/financeProductList

0
votes

The issue is reported with SSL, if you dont need the https protocol, then you could use http in android, but you should add the following line in your manifest.

If you would use https then i recommend to change your SSL Certificate to solve the issue.