File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,12 @@ export async function apiGet(endpoint, isJson = true) {
258
258
method : 'GET' ,
259
259
headers,
260
260
} )
261
+ let resJson
262
+ try {
263
+ resJson = await resp . json ( )
264
+ } catch ( error ) {
265
+ resJson = { }
266
+ }
261
267
if ( resp . status === 401 ) {
262
268
const refreshToken = localStorage . getItem ( 'refresh_token' )
263
269
if ( refreshToken === null ) {
@@ -274,11 +280,13 @@ export async function apiGet(endpoint, isJson = true) {
274
280
throw new Error ( 'Authorization error' )
275
281
}
276
282
if ( resp . status !== 200 ) {
277
- throw new Error ( resp . statusText || `Error ${ resp . status } ` )
283
+ throw new Error (
284
+ resJson ?. error ?. message || resp . statusText || `Error ${ resp . status } `
285
+ )
278
286
}
279
287
if ( isJson ) {
280
288
return {
281
- data : await resp . json ( ) ,
289
+ data : resJson ,
282
290
total_count : resp . headers . get ( 'X-Total-Count' ) ,
283
291
etag : resp . headers . get ( 'ETag' ) ,
284
292
}
You can’t perform that action at this time.
0 commit comments