Mähh
"useAsyncData" does not show error page on "createError"
Hey there, i want to create a composable for my api. Which just is a wrapper for the
useAsyncData
component:
Within that wrapper i want to throw an global error, in case the api response with a status code >= 500
And calling that in my page component:
This console.log
line is shown in the cli (ssr and csr) but the error-page is never shown, not when refreshing the page or navigating using the vue-router.5 replies
Cloudflare Pages - Cached Subrequest / SSR fetch
Hey there, im using Nuxt in a Cloudflare pages runtime.
Using
useFetch
or useAsyncData
on the initial request (SSR) will not do a "real" request, as long the target path is located in server/api
routes, correct?
It just calls the defineEventHandler
, instead of calling the url like useFetch
would do it on client-side.
This could be a problem, when you start to cache api responses through e.g. Cloudflare. That's because the fetch on server-side (uncached) and client-side (cached) can receive different states.
Is there any logic/option to force the fetch method to do an "external request" even on server-side?14 replies
useCookie does share state between layout and component when used in composable
First of all, here is a reproduction: https://stackblitz.com/edit/nuxt-starter-agstq6
It looks like
useCookie
does not share the state like useState
would between vue components.
The useCookie
is used within a composable and have a simple function to change the state on button click.
When i call the state change function from the layout, watch functions in the same layout will trigger.
When i call the state change function from another component, the layout is not aware of the changed state of useCookie
When i saw correctly, there is a closed issue on github regarding it: https://github.com/nuxt/nuxt/issues/13020 including a PR https://github.com/nuxt/nuxt/pull/20970 from June 23 to fix this. But using Nuxt v3.12.2
this bug appears again.6 replies