mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
Fix error handling logic in use Notification hook
This commit is contained in:
1 parent
7bf981e0fa
commit
f86e425e6e
1 file changed
+3
-2
@@ -6,11 +6,12 @@ import { API_URL } from 'lib/constants'
|
||||
|
||||
export const useNotifications = () => {
|
||||
const { data, error, mutate } = useSWR<Notification[]>(`${API_URL}/notifications`, get)
|
||||
const anyError = error !== undefined
|
||||
|
||||
const anyError = (data as any)?.error || error !== undefined
|
||||
const refresh = () => mutate()
|
||||
|
||||
return {
|
||||
notifications: anyError ? undefined : data,
|
||||
notifications: anyError ? [] : data,
|
||||
isLoading: !anyError && !data,
|
||||
isError: !!anyError,
|
||||
refresh,
|
||||
|
||||
Reference in new issue
Block a user