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

Response.body is always undefined #1454

Open
joshmossas opened this issue May 7, 2024 · 1 comment
Open

Response.body is always undefined #1454

joshmossas opened this issue May 7, 2024 · 1 comment

Comments

@joshmossas
Copy link

joshmossas commented May 7, 2024

The fetch standard says that response.body should be null or a body.

https://fetch.spec.whatwg.org/#responses

A response has an associated body (null or a body). Unless stated otherwise it is null.

However this polyfill never sets the body field in Response so it's always undefined. This causes downstream issues for applications that might use response.body to check if a response body exists.

Proposed Change

In fetch.js line 238

fetch/fetch.js

Line 238 in ba5cf1e

this._bodyInit = body

assign the body field

this._bodyInit = body
this.body = body ?? null

I'm willing to open a PR if this proposal looks good to you.

@joshmossas joshmossas changed the title Spec expects Response.body to be defined Response.body is always undefined May 7, 2024
@isocroft
Copy link

isocroft commented Aug 1, 2024

Hello @JakeChampion , any progress on this proposal ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants