File tree Expand file tree Collapse file tree 1 file changed +14
-19
lines changed
Expand file tree Collapse file tree 1 file changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -33,25 +33,20 @@ export async function credFetch(
3333 path : string ,
3434 body ?: unknown ,
3535) : Promise < Response > {
36- try {
37- let idToken = await getIdToken ( ) ;
38- const init : RequestInit = { method } ;
39- if ( body ) {
40- init . body = JSON . stringify ( body ) ;
41- init . headers = {
42- "Content-Type" : "application/json" ,
43- } ;
44- }
45- let res = await fetch ( `${ path } ?token=${ idToken } ` , init ) ;
46-
47- if ( res . status === 401 ) {
48- idToken = await getIdToken ( ) ;
49- res = await fetch ( `${ path } ?token=${ idToken } ` , init ) ;
50- }
36+ let idToken = await getIdToken ( ) ;
37+ const init : RequestInit = { method } ;
38+ if ( body ) {
39+ init . body = JSON . stringify ( body ) ;
40+ init . headers = {
41+ "Content-Type" : "application/json" ,
42+ } ;
43+ }
44+ let res = await fetch ( `${ path } ?token=${ idToken } ` , init ) ;
5145
52- return res ;
53- } catch ( error ) {
54- console . error ( "Error in credFetch function:" , error ) ;
55- throw error ;
46+ if ( res . status === 401 ) {
47+ idToken = await getIdToken ( ) ;
48+ res = await fetch ( `${ path } ?token=${ idToken } ` , init ) ;
5649 }
50+
51+ return res ;
5752}
You can’t perform that action at this time.
0 commit comments