skip to Main Content

I’m trying to run an API call in React Native on Android with Expo using Axios, but I’m encountering a network error. I tried some solutions, but nothing seems to work. This is the error displayed in the console:

Network Error
at node_modules\axios\lib\core\AxiosError.js:3:0in <global>
at node_modules\axios\lib\adapters\xhr.js:138:8 in handleAbort
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:647:10 in setReadyState
at node_modules\react-native\Libraries\Network\XMLHttpRequest.js:396:6 in didCompleteResponse
at node_modules\react-native\Libraries\vendor\emitter_EventEmitter.js:150:10 in EventEmitter#emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:417:4 in callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:114:6 in guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:368:10 in guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:113:4 in callFunctionReturnFlushedQueue

I tried changing the localhost in the API link to my IP address, as well as to 10.0.2.2, but nothing worked. I checked my internet permission in AndroidManifest and made some other permission changes to the file, but nothing seemed to resolve it. I hope to find a solution to the problem soon.

2

Answers


  1. i m the same problem. you found solution l

    Login or Signup to reply.
  2. if you are using a tool like expo go, [axiosError: Network error] is simply an error saying that the api you provided may not be reached.
    so if you want to pull data from a local storage instead of cloud storage … you may create a server like for example php artisan serve then create an Ngrok server for that server , afterwards take the link you received from the ngrok then use it as your new API endpoint

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search