'How can i update the data without using setInterval and websocket?
const [TIME, setData] = useState([]);
useEffect(() => {
axios.get(`${API_ENDPOINT}/api/getPlayersStats`,
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-control-allow-origin': '*'
},
auth: {
username: 'admin',
password: 'password'
},
}).then(response => {
// console.log("aa",response.data);
setData(Object.values(response.data).flat());
}).catch(error => {
console.log(error);
});
}, [])
When I write Axios inside the set interval it runs unnecessarily in the network tab I want when the Backend to update any data API it's reflected in GUI website without using any SetInterval.
Is it possible to update GUI without using WebSocket? backend is written in Java language.
I want when the backend updates it's directly updated in Gui.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
