N
Nuxtβ€’2w ago
otr

WARN [nuxt] useAsyncData should return a value that is not null or undefined or the request may be

With the latest update i get this multiple times, but there is no way to see which code is the cause of this. Would be nice if that would be more specific. In the network tab I see no request that returns null or undefined (maybe it is a server side one) so I am unsure how to debug.
7 Replies
manniL
manniLβ€’2w ago
it might not be a request, it might be useAsyncData where you don't return anything at all πŸ™‚ (requests rarely provide "nothing", often an empty objected, string or array is presented)
otr
otrβ€’2w ago
Thanks! That helped me to figure it out πŸ˜‰
Sebastian
Sebastianβ€’2w ago
@manniL / TheAlexLichter Hi! Found this thread when i encountered this. So a useAsyncData should never return an undefined value if it doesnt find any content during the request? How do i handle that situation then?
manniL
manniLβ€’2w ago
an empty object, string or similar πŸ™‚
Sebastian
Sebastianβ€’2w ago
what is the logic of not allowing undefined? Do you know? In my brain (at least right now) just handling something as not having returned a value is easier than checking if its an empty object πŸ˜› What happens if a useAsyncData doesnt return anythign at all? Does that count towards the warning?
manniL
manniLβ€’2w ago
that's also undefined well, if you result is an empty string or false it is fine too. just not null or undefined πŸ™‚ and you also have transform available (though I'm not 100% sure if that'd fix it)
Sebastian
Sebastianβ€’2w ago
In my head this still seems pretty backwards. This means that a typed return would be broken in the case where i want to return a falsey value transform seems to atleast silence the warning. I assume that means its fine.
Want results from more Discord servers?
Add your server
More Posts