@@ -38,12 +38,12 @@ async function apiRequest<T>(
38
38
return ( await res . json ( ) ) as T ;
39
39
}
40
40
41
- export function useNetBirdFetch ( ) {
41
+ export function useNetBirdFetch ( ignoreError : boolean = false ) {
42
42
const tokenSource = config . tokenSource || "accessToken" ;
43
43
const { idToken } = useOidcIdToken ( ) ;
44
44
const { accessToken } = useOidcAccessToken ( ) ;
45
45
const token = tokenSource . toLowerCase ( ) == "idtoken" ? idToken : accessToken ;
46
- const handleErrors = useApiErrorHandling ( ) ;
46
+ const handleErrors = useApiErrorHandling ( ignoreError ) ;
47
47
48
48
const isTokenExpired = async ( ) => {
49
49
let attempts = 20 ;
@@ -77,9 +77,9 @@ export function useNetBirdFetch() {
77
77
} ;
78
78
}
79
79
80
- export default function useFetchApi < T > ( url : string ) {
81
- const { fetch } = useNetBirdFetch ( ) ;
82
- const handleErrors = useApiErrorHandling ( ) ;
80
+ export default function useFetchApi < T > ( url : string , ignoreError = false ) {
81
+ const { fetch } = useNetBirdFetch ( ignoreError ) ;
82
+ const handleErrors = useApiErrorHandling ( ignoreError ) ;
83
83
84
84
const { data, error, isLoading, isValidating, mutate } = useSWR (
85
85
url ,
@@ -102,9 +102,9 @@ export default function useFetchApi<T>(url: string) {
102
102
} as const ;
103
103
}
104
104
105
- export function useApiCall < T > ( url : string ) {
106
- const { fetch } = useNetBirdFetch ( ) ;
107
- const handleErrors = useApiErrorHandling ( ) ;
105
+ export function useApiCall < T > ( url : string , ignoreError = false ) {
106
+ const { fetch } = useNetBirdFetch ( ignoreError ) ;
107
+ const handleErrors = useApiErrorHandling ( ignoreError ) ;
108
108
109
109
return {
110
110
post : async ( data : any , suffix = "" ) => {
@@ -130,10 +130,15 @@ export function useApiCall<T>(url: string) {
130
130
} ;
131
131
}
132
132
133
- export function useApiErrorHandling ( ) {
133
+ export function useApiErrorHandling ( ignoreError = false ) {
134
134
const { login } = useOidc ( ) ;
135
135
const currentPath = usePathname ( ) ;
136
136
const { setError } = useErrorBoundary ( ) ;
137
+ if ( ignoreError )
138
+ return ( err : ErrorResponse ) => {
139
+ console . log ( err ) ;
140
+ return Promise . reject ( err ) ;
141
+ } ;
137
142
138
143
return ( err : ErrorResponse ) => {
139
144
if ( err . code == 401 && err . message == "no valid authentication provided" ) {
0 commit comments