N
Nuxt2y ago
cosbgn

non navigation blocking middleware

I have something like this:
// middleware/billing.js
export default defineNuxtRouteMiddleware(async (to, from) => {
if (process.server){ return; }
const state = useState('billing')
state.value = !state.value ? await $fetch("/api/billing") : state.value;
})
// middleware/billing.js
export default defineNuxtRouteMiddleware(async (to, from) => {
if (process.server){ return; }
const state = useState('billing')
state.value = !state.value ? await $fetch("/api/billing") : state.value;
})
Is it possible to somehow have it lazy? so that it doesn't block navigation?
1 Reply
cosbgn
cosbgnOP2y ago
Currently my page load only after the middleware resoles which slow down things by a second or more I don't need to know the billing before page load Ideally I would like to run it onMounted for example
Want results from more Discord servers?
Add your server