It seems that useFetch for post api don't work in onMounted . Do you know what the cause is?
BTW, useFetch for get api work in onMounted.
Reproduction: https://github.com/mogi86/study-nuxt3-v2/blob/v0.0.5/src/pages/api_from_client.vue
1 messages · Page 1 of 1 (latest)
It seems that useFetch for post api don't work in onMounted . Do you know what the cause is?
BTW, useFetch for get api work in onMounted.
Reproduction: https://github.com/mogi86/study-nuxt3-v2/blob/v0.0.5/src/pages/api_from_client.vue
My get request is also not working 😕
But $fetch works.
When I use useFetch it don't even send the request 😅
Btw is it legal to use onMounted in nuxt ?? Don't seem to find anything about this lifecycle.
Thanks. My post api also worked when I used $fetch.
I want to know why $fetch works, so I looked for the documentation but could not find it...
Btw is it legal to use onMounted in nuxt ??
For example, it may need onMounted when I want to execute a save process that is not related to the rendering and don’t block the rendering. However, useLazyFetch instead of $fetch may also work. In my understand, useLazyFetch don’t block the rendering.
@river stone instead of doing that in onMounted, why not using the server: false option
@vale skiff
post api worked when I use server: false option and useLazyFetch . thanks
https://github.com/mogi86/study-nuxt3-v2/blob/870c8a156ec95cb1070efea5ef7fb53f07c2b8b1/src/pages/fetch_lazy_fetch_call_post_api.vue#L12-L18