Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use response._bodyInit as fallback for react-native and qq #398

Merged
merged 11 commits into from
Oct 8, 2024
9 changes: 7 additions & 2 deletions src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
}

const hasBody =
context.response.body &&
(context.response.body ||
// https://github.com/unjs/ofetch/issues/324
// https://github.com/unjs/ofetch/issues/294
// https://github.com/JakeChampion/fetch/issues/1454
(context.response as any)._bodyInit) &&
joshmossas marked this conversation as resolved.
Show resolved Hide resolved
!nullBodyResponses.has(context.response.status) &&
context.options.method !== "HEAD";
if (hasBody) {
Expand All @@ -213,7 +217,8 @@ export function createFetch(globalOptions: CreateFetchOptions = {}): $Fetch {
break;
}
case "stream": {
context.response._data = context.response.body;
context.response._data =
context.response.body || (context.response as any)._bodyInit; // (see refs above)
break;
}
default: {
Expand Down