File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -27,10 +27,11 @@ import {
27
27
replayHistory ,
28
28
generateHistoryEntry ,
29
29
getStxProcessingTime ,
30
+ handleFetch ,
30
31
} from './utils' ;
31
32
import { CHAIN_IDS } from './constants' ;
32
33
33
- const { handleFetch , safelyExecute } = util ;
34
+ const { safelyExecute } = util ;
34
35
35
36
// TODO: JSDoc all methods
36
37
// TODO: Remove all comments (* ! ?)
Original file line number Diff line number Diff line change @@ -149,3 +149,20 @@ export const getStxProcessingTime = (
149
149
}
150
150
return Math . round ( ( Date . now ( ) - smartTransactionSubmittedtime ) / 1000 ) ;
151
151
} ;
152
+
153
+ export async function handleFetch ( request : string , options ?: RequestInit ) {
154
+ const response = await fetch ( request , options ) ;
155
+ const json = await response . json ( ) ;
156
+ if ( ! response . ok ) {
157
+ const { error : type , error_details : message } = json ;
158
+ console . log ( `response` , response ) ;
159
+ throw new Error (
160
+ `Fetch error:${ JSON . stringify ( {
161
+ status : response . status ,
162
+ type,
163
+ message,
164
+ } ) } `,
165
+ ) ;
166
+ }
167
+ return json ;
168
+ }
You can’t perform that action at this time.
0 commit comments