0👍
✅
You should probably just use the $fetchState.pending
rather than your isLoading
state. Since it’s a duplicate and that the fetch()
hook just handles it by itself.
Also, why do you not write your whole logic in the fetch()
hook ? Make it async/await
and it will work great (there is no await
in your code, you’re using then
at a place) !
Here is an example on how to handle the loading state while fetching an API thanks to the fetch hook: https://codesandbox.io/s/use-nuxt-fetch-hook-on-api-5ymdz?file=/pages/index.vue
Source:stackexchange.com