The Post request works, however, It's only working until 5 button presses max on android, 4x on iOS. I'm not sure if this limit is caused by express, express router, Axios. Many thanks.
//client:
const [i, setI] = useState(0)
const [connecter, setConnecter] = useState()
const mainURL = "http://localhost:8080/usr"
const datas = {
val : "counter!" + " " + i
}
const func = () => {
setI(i + 1)
axios({
method: 'post',
url: mainURL + "/play",
data: JSON.stringify(datas),
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
maxContentLength: Infinity,
maxBodyLength: Infinity
})
.then(() => {
console.log("sent!")
})
.catch(err => console.log(err))
};
const red = axios.get(mainURL + "/connect",
{headers:{"Content-Type": "application/json"}})
.then((res) => {
setConnecter(res.status)
}).catch((err) => setConnecter(err))
useEffect(() => {
}, [red])
//server
router.get("/connect", (req, res) => {
res.send("Server Connected")
})
router.post("/play", async(req, res) => {
const resser = await req.body
console.log(resser)
})
Android showing server status 200 (connected)