I use fetch sending image to a server.
On iOS everythin works as expected, but on android i get Request fialed.
The uri i get from expo image picker, on IOS everything works as expected.
const form = new FormData();
form.append('file', {
uri: imageUri,
name: 'file.jpg',
fileName: 'file',
});
fetch(api,{
method: 'post',
body: form,
})
.then(response => response.text())
.then(textResponse => {
console.log(textResponse);
Alert.alert(textResponse);
if (textResponse){
setAccuracyResponse(textResponse);
}
})
.catch(error => {
console.error(error)
});
on android i get this response
Network request failed
- node_modules/whatwg-fetch/dist/fetch.umd.js:535:17 in setTimeout$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:383:16 in callTimers
- 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
Expo sdk v39
Expo version 3.28.5
node v14.15.0
npm 6.14.8