Im using fetch API to retrieve data from my node server to react native application. It works well when I execute the app in Android Studio emulator or a phsycal device, but when I build it to export external APK, app cannot perform request. Type Error: Network request failed Error img This is the fetch in React Native
NetInfo.fetch().then(state => {
if (state.isConnected) {
fetch('http://example/API2/clients', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
nombre: this.state[key],
}),
})
.then(response => response.json())
.then(responseJson => {
console.log(responseJson);
})
.catch(error => {
console.log(error);
Alert.alert(
'Lo sentimos',
'No se ha recibido respuesta del servidor' + error,
);
});
} else {
Alert.alert('Sin conexión a internet', 'Verifique su conexión');
}
});
I noticed request are not even getting out from client. React-native version: 0.61