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
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)
Thanks! That helped me to figure it out π
@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?
an empty object, string or similar π
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?
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)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.