File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
console/atest-ui/src/views Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -22,14 +22,24 @@ async function DefaultResponseProcess(response: any) {
2222 throw new Error ( "Unauthenticated" )
2323 }
2424
25- const message = await response . json ( ) . then ( ( data : any ) => data . message )
26- throw new Error ( message )
27- } else {
28- const contentType = response . headers . get ( 'Content-Type' ) || '' ;
29- if ( contentType . includes ( ' text/plain' ) ) {
30- return response . text ( ) ;
25+ try {
26+ const message = await response . json ( ) . then ( ( data : any ) => data . message )
27+ throw new Error ( message )
28+ } catch {
29+ const text = await response . text ( )
30+ throw new Error ( text )
3131 }
32- return response . json ( ) ;
32+ }
33+
34+ const contentType = response . headers . get ( 'Content-Type' ) || '' ;
35+ if ( contentType . startsWith ( 'text/plain' ) ) {
36+ return response . text ( ) ;
37+ }
38+ try {
39+ return await response . json ( ) ;
40+ } catch ( e ) {
41+ // If JSON parsing fails, return as text
42+ return response . text ( ) ;
3343 }
3444}
3545
You can’t perform that action at this time.
0 commit comments