11export const fetchFileContent = async (
22 url ,
3- fallbackUrl ,
43 config = { }
54) => {
65 const {
@@ -15,21 +14,21 @@ export const fetchFileContent = async (
1514
1615 let attempts = 0 ;
1716
18- const attemptFetch = async ( currentUrl ) => {
17+ const attemptFetch = async ( ) => {
1918 if ( signal ?. aborted ) {
2019 throw new DOMException ( 'Aborted' , 'AbortError' ) ;
2120 }
2221
2322 attempts ++ ;
2423 onAttempt ?. ( attempts ) ;
2524
26- const response = await fetch ( currentUrl , { signal } ) ;
25+ const response = await fetch ( url , { signal } ) ;
2726
2827 if ( response . status === 202 && polling ) {
2928 if ( attempts < maxAttempts ) {
3029 return new Promise ( ( resolve , reject ) => {
3130 const timeoutId = setTimeout ( ( ) => {
32- attemptFetch ( url ) . then ( resolve ) . catch ( reject ) ;
31+ attemptFetch ( ) . then ( resolve ) . catch ( reject ) ;
3332 } , interval ) ;
3433
3534 signal ?. addEventListener ( 'abort' , ( ) => {
@@ -43,10 +42,7 @@ export const fetchFileContent = async (
4342 }
4443
4544 if ( ! response . ok ) {
46- if ( fallbackUrl ) {
47- return attemptFetch ( fallbackUrl ) ;
48- }
49- throw new Error ( `Failed fetching from ${ currentUrl } with status code ${ response . status } ` ) ;
45+ throw new Error ( `Failed fetching from ${ url } with status code ${ response . status } ` ) ;
5046 }
5147
5248 const text = await response . text ( ) ;
@@ -55,7 +51,7 @@ export const fetchFileContent = async (
5551 } ;
5652
5753 try {
58- return await attemptFetch ( url ) ;
54+ return await attemptFetch ( ) ;
5955 } catch ( error ) {
6056 if ( error . name === 'AbortError' ) {
6157 console . warn ( 'Polling aborted' ) ;
0 commit comments