'Expo Android requests being blocked
I'm developing an Expo app on both Android and IOS. I am making the same API request on both IOS and Android but for some reason the Android request is failing.
try {
const res = await fetch('https://mymarketnews.ams.usda.gov/public_data/ajax-get-
commodities/');
const json = await res.json();
console.log(json);
} catch (e) {
console.log(e)
}
I am recieving the following error on Android:
Network request failed
- node_modules/whatwg-fetch/dist/fetch.umd.js:527:17 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:135:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:387:16 in callTimers
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:425:19 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:6 in
__guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:373:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:4 in
callFunctionReturnFlushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
I have tried adding an explicit method property on the fetch request as well as some basic headers but nothing seems to work.
Expo version: 3.27.4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|