Skip to content

Commit bb80ee1

Browse files
committed
feat: Handle 204 No Content responses and improve JSON parsing logic
1 parent fe7efc6 commit bb80ee1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/services/BaseGitHubService.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ export abstract class BaseGitHubService {
4444
throw apiError;
4545
}
4646

47-
return await response.json();
47+
// Return null for 204 No Content responses
48+
if (response.status === 204) {
49+
return null;
50+
}
51+
52+
// Only try to parse JSON if there's actual content
53+
const contentLength = response.headers.get('content-length');
54+
const hasContent = contentLength === null || parseInt(contentLength) > 0;
55+
56+
if (hasContent) {
57+
return await response.json();
58+
}
59+
60+
return null;
4861
}
4962
}

0 commit comments

Comments
 (0)