N
Nuxt10mo ago
Thiimo

How to assert non-null with data fetching

How would you assert the profile.value to be non null? The best senario would be to use a middleware to check if the user is loggedin and redirect them to the login page if they are not. The problem I'm facing is that the editor doesn't know that the user won't get on the page if the user is not logged in.
No description
3 Replies
manniL
manniL10mo ago
either put it in else, asser it via profile.value! or similar as TS does not know that the code will stop after navigateTo and you can't early return in script setup
manniL
manniL10mo ago
you can also put it in a function and return early there, then call it (inline composable) - example
Alexander Lichter
YouTube
Organize your Composition API code (2k subscriber special)
✨ The Composition API is amazing - but organizing code is still a challenge sometimes, especially for all the people that were (or are) used to the Options API. In this video I point out common mistakes when organizing code and an easy way to avoid spaghetti code in Vue components with a bit more functionality Key points: ✔ Building a Demo Appl...
Thiimo
ThiimoOP10mo ago
Thanks, will look into these options!
Want results from more Discord servers?
Add your server