Skip to content

Commit 3617666

Browse files
authored
fix: use response._bodyInit as fallback for react-native and qq (#398)
1 parent 80aa991 commit 3617666

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: src/fetch.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,11 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
203203
}
204204

205205
const hasBody =
206-
context.response.body &&
206+
(context.response.body ||
207+
// https://github.com/unjs/ofetch/issues/324
208+
// https://github.com/unjs/ofetch/issues/294
209+
// https://github.com/JakeChampion/fetch/issues/1454
210+
(context.response as any)._bodyInit) &&
207211
!nullBodyResponses.has(context.response.status) &&
208212
context.options.method !== "HEAD";
209213
if (hasBody) {
@@ -222,7 +226,8 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
222226
break;
223227
}
224228
case "stream": {
225-
context.response._data = context.response.body;
229+
context.response._data =
230+
context.response.body || (context.response as any)._bodyInit; // (see refs above)
226231
break;
227232
}
228233
default: {

0 commit comments

Comments
 (0)