Well, in order to be able to detect the status of browsers, if users are on the site, I want to send a request if they close the browser and change a feature in a model. It should be noted that this model is different from the user model in Django.
Also, I'm using Django sessions and SESSION_EXPIRE_AT_BROWSER_CLOSE=True
but that's not working.
So I use React window.onblur event and that's not working again!
I try this code in react but it's not working!
let stid:string|null=localStorage.getItem('stationid')
useEffect(() => {
window.onblur=()=>{
console.log('hello')
Api.delete(STATION_ID(stid)).then((res)=>{
console.log(res.data)
}).catch(err=>{
console.log(err)
})
}
return () => {
console.log('hello')
}
}, [])