useLazyFetch error Nuxt 3.4
Hey!
I get the following console log when a GET request is made (with the code above), however the error object returned by the lazyFetch is not useful (see image):
This was working fine when I was on rc14
My headers and URL is correct to the best of my knowledge
When I change from useLazyFetch to useFetch it works. But I don't want to block navigation till after the API calls. Any ideas?
13 Replies
Well you'd want to log error.value atleast as the error object is a ref
So something like this: https://stackblitz.com/edit/github-x56zdm-rsfkvq?file=pages%2Ftest.vue
error.value
is undefined
Hence the confusioncheck my example
It doesn't work either?
Changing the code to yields:
Sorry being a dumbass there, incorrect url presents valid error
yep
So why does
let {data:data, pending:pending, refresh:refresh, error:error} = await useLazyFetch(url, {headers:headers})
present an error, when let {data:data, pending:pending, refresh:refresh, error:error} = await useFetch(url, {headers:headers})
works just fine?
Ah I get it
got*
!== should've been !=
😩
I do have another issue tho if you're not busyI have a list of player profiles as shown in the image. When I load this page for the first time, and click the "View Profile" button for a profile, the data is not fetched from the API, as in I get a null from the
data
attribute. When I go back to the shown profiles page, and click the same View Profile (same profile), it loads just fine, and the data is returnedSo since youre explicitly calling useFetchLazy which is not render blocking there will be a time window while data will be null
which you have to handle
on the second request it works due to caching
atleast thats my guess
So on my page I have
is that not enough?
changing the v-else to v-else-if="player" worked
Got that's stupid
Thanks dude
Just out of curiousity, have you tried v-if="pending" .. v-else..?
Yeah I removed the && player part and it had the same issue
That's strange
if you can reproduce it on stackblitz might be worth raising an issue