簡體   English   中英

Axios React Native 網絡錯誤 Android Expo

[英]Axios Network Error in React Native with Expo in Android

我正在嘗試使用 Axios 在 Android 和 Expo 上的 React Native 中運行 API 調用,但我遇到了網絡錯誤。 我嘗試了一些解決方案,但似乎沒有任何效果。 這是控制台中顯示的錯誤:

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

我嘗試將 API 鏈接中的本地主機更改為我的 IP 地址以及 10.0.2.2,但沒有任何效果。 我在 AndroidManifest 中檢查了我的 inte.net 權限並對文件進行了一些其他權限更改,但似乎沒有任何解決辦法。 我希望盡快找到解決問題的辦法。

如果您使用的是 expo go 之類的工具,[ axiosError: Network error ] 只是一個錯誤,表示您提供的 api 可能無法訪問。 所以如果你想從本地存儲而不是雲存儲中提取數據......你可以創建一個服務器,例如php artisan serve然后為該服務器創建一個 Ngrok 服務器,然后獲取你從 ngrok 收到的鏈接然后使用它作為您的新 API 端點

我有同樣的問題。 你找到了解決方案 l

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM