File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,16 @@ export function normalizeDomain(domain: string): string {
2525}
2626
2727export async function httpCall < JsonResponse > ( url : string , init ?: RequestInit ) : Promise < JsonResponse > {
28- const response = await fetch ( url , init ) ;
29-
30- if ( response . status >= 200 && response . status <= 299 ) {
31- return ( await response . json ( ) ) as JsonResponse ;
32- }
33-
34- throw new Error ( response . statusText ) ;
28+ return await fetch ( url , init ) . then ( async ( response ) => {
29+ if ( response . status >= 200 && response . status <= 299 ) {
30+ return ( await response . json ( ) ) as JsonResponse ;
31+ }
32+ throw new Error ( response . statusText ) ;
33+ } ) . then ( ( response ) => {
34+ return response ;
35+ } ) . catch ( ( error ) => {
36+ throw new Error ( error ) ;
37+ } )
3538}
3639
3740export function addWindowEventListener ( eventType : string , callback : any ) : ( ) => void {
You can’t perform that action at this time.
0 commit comments