( url: string, params: Parameters<typeof fetch>[1], isRetry = false, )
| 136 | }; |
| 137 | |
| 138 | export const enhancedFetch = async ( |
| 139 | url: string, |
| 140 | params: Parameters<typeof fetch>[1], |
| 141 | isRetry = false, |
| 142 | ): Promise<Response> => { |
| 143 | return fetch(url, params) |
| 144 | .catch(e => { |
| 145 | log('fetch error', url, e); |
| 146 | if (isRetry) { |
| 147 | throw e; |
| 148 | } |
| 149 | log('trying fallback to http'); |
| 150 | return enhancedFetch(url.replace('https', 'http'), params, true); |
| 151 | }); |
| 152 | }; |
no test coverage detected