Skip to content

Commit 508f313

Browse files
chore(client): do not parse responses with empty content-length
1 parent c8b9446 commit 508f313

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/internal/parse.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Arcade, props: APIResponse
2929
const mediaType = contentType?.split(';')[0]?.trim();
3030
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
3131
if (isJSON) {
32+
const contentLength = response.headers.get('content-length');
33+
if (contentLength === '0') {
34+
// if there is no content we can't do anything
35+
return undefined as T;
36+
}
37+
3238
const json = await response.json();
3339
return json as T;
3440
}

0 commit comments

Comments
 (0)