Skip to content

Response.body is always undefined #1454

Open
@joshmossas

Description

@joshmossas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions