NuxtN
Nuxt3y ago
Gerbuuun

useFetch adds null to return type

When using
useFetch
to fetch data from server api routes,
useFetch
adds
null
as a union to the return type.
Because I use typescript strict mode, this forces me to do null checks to api routes which already handle this.
If I understand correctly, when using SSR,
useFetch
is just an async function call to the api endpoints?
Then why does it add null to the type?

If this works as intended, how would I check if the data is null inside script setup
image.png
image.png
Was this page helpful?