Reload data
Hello, i recently came across a problem when reloading the /admin page.
My problem is that my js function useFetch() is not triggered when I reload the page manually, so the data of my ref() function dashboardData is empty
It works fine when navigating through my app. What should i do to to fix it?
My problem is that my js function useFetch() is not triggered when I reload the page manually, so the data of my ref() function dashboardData is empty
It works fine when navigating through my app. What should i do to to fix it?
<script setup>
const {
dashboardData,
getDashboardData,
} = useDashboard()
await getDashboardData()
</script><script setup>
const {
dashboardData,
getDashboardData,
} = useDashboard()
await getDashboardData()
</script>const fetchSanctum = async (url, options = {method: 'GET'}) => {
const router = useRouter()
const userStore = useAuthStore()
const config = useRuntimeConfig()
let token = useCookie('XSRF-TOKEN').value
if (options.method !== 'GET' && !token) {
await useFetch('/sanctum/csrf-cookie', {
method: 'GET',
credentials: 'include',
baseURL: config.public.baseURL,
})
token = useCookie('XSRF-TOKEN').value
}
return await useFetch(url, {
...{
credentials: 'include',
baseURL: config.public.baseURL + '/api',
headers: {
'X-XSRF-TOKEN': token,
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'Access-Control-Allow-Credentials': true,
},
}, ...options
})
}const fetchSanctum = async (url, options = {method: 'GET'}) => {
const router = useRouter()
const userStore = useAuthStore()
const config = useRuntimeConfig()
let token = useCookie('XSRF-TOKEN').value
if (options.method !== 'GET' && !token) {
await useFetch('/sanctum/csrf-cookie', {
method: 'GET',
credentials: 'include',
baseURL: config.public.baseURL,
})
token = useCookie('XSRF-TOKEN').value
}
return await useFetch(url, {
...{
credentials: 'include',
baseURL: config.public.baseURL + '/api',
headers: {
'X-XSRF-TOKEN': token,
'Accept': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
'Access-Control-Allow-Credentials': true,
},
}, ...options
})
}