my problem is that I get the token from the backend and I set it to local storage but when the user logs into the account data won't show to the user. but when the user refreshes the page, data would show to the user. what do you think is the problem? thank you for your time!
const dashboardHeader = async () => {
await axios.get('adminPanel/dashboard', {
params: {
fromDate: 'notSet',
toDate: 'notSet'
}
})
.then(res => {
setHeaderData(res?.data?.result?.header)
setLoading(false)
})
.catch(err => {
console.log(err)
})
}
this is one of my api examples
the page has to refresh after the token is set.