当我尝试使用 react-native 中的 fetch 从 cloudinary 获取图像列表时,出现以下错误。如何解决这个问题?
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (C:\workspace\react_native\Gallery\node_modules\react-native\node_modules\whatwg-fetch\fetch.js:441)
at XMLHttpRequest.dispatchEvent (C:\workspace\react_native\Gallery\node_modules\event-target-shim\lib\event-target.js:172)
at XMLHttpRequest.setReadyState (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:567)
at XMLHttpRequest.__didCompleteResponse (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:397)
at C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:503
at RCTDeviceEventEmitter.emit (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:179)
at MessageQueue.__callFunction (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:351)
at C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116
at MessageQueue.__guardSafe (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:314)
at MessageQueue.callFunctionReturnFlushedQueue (C:\workspace\react_native\Gallery\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115)
Run Code Online (Sandbox Code Playgroud) 当我使用 axios 从客户端(React JS)向服务器(spring)发出 post 请求时,服务器的响应时间超过 2 分钟。因此,当需要更多 tan 2 分钟时,客户端不会等待接收响应。所以我试图用下面的代码片段覆盖默认超时。但它不起作用。请帮助我解决问题。
const httpClient = Axios.create();
httpClient.defaults.timeout = 240000;
return httpClient.post(url, data).then(
res => res
).catch(err => err);
Run Code Online (Sandbox Code Playgroud) android ×1
axios ×1
cloudinary ×1
fetch-api ×1
javascript ×1
react-native ×1
reactjs ×1
settimeout ×1
timeout ×1