T
TanStack2y ago
absent-sapphire

204s - Null Or Undefined

When accessing via axios., a rest resource that could return an object or a 204 - no content. Is it better practice directly return the undefined from res?.data or manipulate that into a null for the consumer of the useQuery inside the queryFN.
i.e should the type be ResponseObject | undefined or ResponseObject | null. return res?.data or return res?.data ?? null
1 Reply
other-emerald
other-emerald2y ago
You shouldn't return undefined from the queryFn. There should be a warning in dev mode if that happens

Did you find this page helpful?