Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Axios request getting network error on Expo

$
0
0

I have an expo mobile application running on an Android emulator and I'm trying to make a request to a local Node.js API. The request is through HTTPS protocol so I created self-signed certificates to be able to try the application.

Every time I try to make a request to the API Axios throws a Network error.

Network ErrorStack trace:  http://192.168.1.35:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:168381:25 in createError  http://192.168.1.35:19001/node_modules%5Cexpo%5CAppEntry.bundle?  platform=ios&dev=true&hot=false&minify=false:168285:26 in handleError  node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent  node_modules\react-native\Libraries\Network\XMLHttpRequest.js:600:10 in setReadyState  node_modules\react-native\Libraries\Network\XMLHttpRequest.js:395:6 in __didCompleteResponse  node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard  node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in   callFunctionReturnFlushedQueue  [native code]:null in callFunctionReturnFlushedQueue  ...

I tried the following:

  • Configuring the API IP on the mobile application as 10.0.2.2 as suggested in the GitHub issue and didn't work.
  • Testing the application without HTTPS, which works perfectly fine.
  • Testing my application on an iOS device, but it has the same behaviour as the Android emulator, it works with HTTP but it does not with HTTPS.
  • Accessing the HTTPS URL from the emulator's browser, which also works.

My HTTPS server is configured as follows:

const httpsServer = https.createServer(Certificate.getCertificate(), app);httpsServer.listen(Environment.PORT, "0.0.0.0");Logger.logInfo(`Listening on port ${Environment.PORT} under HTTPS protocol.`);

In order to create the self-signed certificates, I followed the Heroku guide


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>