Nuxt3 : Redirect in script setup
Hi guys,
I'm requesting my API in my setup, and i want to redirect to a page and stop the rest of the setup when it returns me an error.
I'm using navigateTo, it's working but the console shows me errors of undefined properties on the variable i set with my API response
4 Replies
If the response is not ok, data will not have the myVar value
Even though you navigate, the flow will continue as the navigation does not block in the „onResponse“
Ok, but when i do this, it's the same result. How can i do to redirect and abort the end of the setup ?
you can try
await navigateTo
It's not working.
I just tried to put
await navigateTo(...);
outside any function, just bellow my useFetch
, and it's still the same issue, my data is null and so all the code bellow using this is in error
Up ?