File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ const retryStatusCodes = new Set([
91
91
504 , // Gateway Timeout
92
92
] ) ;
93
93
94
+ // https://developer.mozilla.org/en-US/docs/Web/API/Response/body
95
+ const nullBodyResponses = new Set ( [ 101 , 204 , 205 , 304 ] ) ;
96
+
94
97
export function createFetch ( globalOptions : CreateFetchOptions = { } ) : $Fetch {
95
98
const {
96
99
fetch = globalThis . fetch ,
@@ -222,7 +225,11 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
222
225
return await onError ( context ) ;
223
226
}
224
227
225
- if ( context . response . body ) {
228
+ const hasBody =
229
+ context . response . body &&
230
+ ! nullBodyResponses . has ( context . response . status ) &&
231
+ context . options . method !== "HEAD" ;
232
+ if ( hasBody ) {
226
233
const responseType =
227
234
( context . options . parseResponse
228
235
? "json"
You can’t perform that action at this time.
0 commit comments