For simplicity assume that I have entity user and in my frontend side (react) I am making an Axios get request to get all users to display them.
In the componentDidMount
I am doing a get request const res = axios.get(myurl)
then map the res
to be displayed.
However, if a new user is entered in the database I have to refresh the page to see the update.
Here is my question, how to make the get request to be like running or something like this so if any changes happens in the database it reflects the get request.
You can use the useEffect in react
import React,{useEffect}from 'react'
function getAllUsers(){
//your code here...
}
useEffect(()=>{
getAllUsers();
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With