so I have a function that works when a button is clicked, and inside that function there's a fetch method to post some data to the backend (flask) when I'm using a real android device (note 9 and note 3 ) it doesn't post anything,and I don't get any errors, meanwhile the android emulator is working fine and posts the data.
the solutions I found for that problem is to use internal IP address instead of localhost. but it didn't work for me too. and if I used localhost or 127.0.0.1 I get " network request failed". I also tried to use axios but I get the same results.
getloc = () => {
setInterval(() => {
fetch("http://192.168.1.107:5000/api/echo", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({
x: "0",
y: "0"
})
})
.then(response => response.json())
.then(responseJson => {
this.setState({
xMaster: responseJson.x
});
this.setState({
yMaster: responseJson.y
});
})
.catch(error => {
console.error(error);
});
}, 3000);
};