I need to get the value ( totaluser ) as soon as possible , but when the server change the data ( totaluser ) , the reponse is not stable about the time returning , sometimes get the reponse for 30ms and sometimes get for 5000ms , can someone give any solution to get this more stable and get better about the performance ? , i just want to get the value as soon as possible when the server update it? i am not coding the backend .
var refreshIntervalId = setInterval(function () {
fetch('**the link for api **')
.then(res => res.json()).then((out) => {
var variable = out.totalUser[0].count;
if( variable > 20 ){
// do something ...
}
})
}, 10);