diff --git a/src/core.ts b/src/core.ts index 9cd99639d..75cb120c6 100644 --- a/src/core.ts +++ b/src/core.ts @@ -49,6 +49,11 @@ async function defaultParseResponse(props: APIResponseProps): Promise { return Stream.fromSSEResponse(response, props.controller) as any; } + // fetch refuses to read the body when the status code is 204. + if (response.status === 204) { + return null as T; + } + const contentType = response.headers.get('content-type'); if (contentType?.includes('application/json')) { const json = await response.json();