I have a function which sends http request to the server and I am calling it. I want to do some actions when the request inside that function is finished. How do I know if it's done?
const getUsers =()=> {
// Request goes here
axios({...})
.then(res => {
// Request is finished
})
.catch(err => {})
}
const doSomethingWhenrequestIsFinished =()=> {
getUsers()
// Execute the rest of the code only after the response is back
handleDoSomething()
}
I am using React and I don't want to use useState to keep track of the request state. How else can I know if the response is back or not?