File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
extension/js/common/api/shared Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,14 @@ export class Api {
246246 } else if ( resFmt === 'json' ) {
247247 try {
248248 const transformed = transformResponseWithProgressAndTimeout ( ) ;
249- return ( await Promise . all ( [ transformed . response . json ( ) , transformed . pipe ( ) ] ) ) [ 0 ] as FetchResult < T , RT > ;
249+ return (
250+ await Promise . all ( [
251+ transformed . response . text ( ) . then ( text => {
252+ return ( text ? JSON . parse ( text ) : { } ) as T ; // Handle empty response body
253+ } ) ,
254+ transformed . pipe ( ) ,
255+ ] )
256+ ) [ 0 ] as FetchResult < T , RT > ;
250257 } catch ( e ) {
251258 // handle empty response https://github.com/FlowCrypt/flowcrypt-browser/issues/5601
252259 if ( e instanceof SyntaxError && ( e . message === 'Unexpected end of JSON input' || e . message . startsWith ( 'JSON.parse: unexpected end of data' ) ) ) {
You can’t perform that action at this time.
0 commit comments