Skip to content

Fetch API does not support getReader (response.body is undefined) #37505

Description

@lafkpages

Description

When trying to read the response from Fetch as a stream, via getReader(), I get an error saying that resp.body is undefined. Logging the value of resp shows this:

{"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "xxx", "name": "chat.txt", "offset": 0, "size": 42, "type": "text/plain"}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "xxx", "name": "chat.txt", "offset": 0, "size": 42, "type": "text/plain"}}, "bodyUsed": false, "headers": {"map": {"cache-control": "no-store", "content-length": "42", "content-type": "text/plain; charset=utf-8", "date": "Sun, 21 May 2023 18:53:09 GMT", "expect-ct": "max-age=2592000, report-uri=\"https://sentry.repl.it/api/10/security/?sentry_key=xxx\"", "replit-cluster": "hacker", "strict-transport-security": "max-age=6123043; includeSubDomains", "uwebsockets": "20"}}, "ok": true, "status": 200, "statusText": "", "type": "default", "url": "https://xxx.luisafk.repl.co/chat"}

Duplicate of #25701 and #25910, but they were closed.

React Native Version

0.71.7

Output of npx react-native info

System:
    OS: macOS 12.6.3
    CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
    Memory: 346.30 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.7.0 - ~/.nvm/versions/node/v19.7.0/bin/node
    Yarn: 1.22.15 - ~/.nvm/versions/node/v19.7.0/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v19.7.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK: Not Found
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.7 => 0.71.7 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Try the code example below.

Snack, code example, screenshot, or link to a repository

const resp = await fetch('https://example.com');
const reader = resp.body.getReader();

Activity

  1. github-actions commented on May 21, 2023

    @github-actions
    ⚠️ Newer Version of React Native is Available!
    ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.71.8. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
  2. lafkpages commented on May 21, 2023

    @lafkpages
    Author

    I upgraded and it still does not work.

  3. Liquidibrium commented on Jun 3, 2023

    @Liquidibrium

    Same issue: respnse.json() is valid, however response.body is undefined

  4. rbndg commented on Aug 18, 2023

    @rbndg

    This issue has been lingering in RN for so long and many people have complained about it.
    As it stands now fetch within RN is not spec complaint
    #27741

  5. codergautam commented on Aug 28, 2023

    @codergautam

    Any update? Do I have to use third party fetch?

  6. lafkpages commented on Aug 28, 2023

    @lafkpages
    Author

    Since what I wanted to do was streaming, I ended up using WebSockets, but this should really just be fixed.

  7. github-actions commented on Feb 25, 2024

    @github-actions

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  8. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 25, 2024
  9. rbndg commented on Feb 25, 2024

    @rbndg
  10. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 25, 2024
  11. etler commented on May 3, 2024

    @etler

    With all the AI APIs using SSE this is becoming more and more important. I can use websockets for internal streaming, but where we need to support SSE style APIs that's not an option. Most commercial APIs will prefer to offer streaming over HTTP.

  12. LunatiqueCoder commented on Sep 20, 2024

    @LunatiqueCoder

    I managed to find a solution here: #27741

  13. yukukotani commented on Dec 29, 2024

    @yukukotani

    For Expo users, Expo v52 introduces expo/fetch API which is Winter-CG compliant. We can simply use it instead of native fetch API.

  14. NiuGuohui commented on Mar 19, 2025

    @NiuGuohui

    Can the ReactNative team take a look at this requirement?
    @cortinico

  15. gajrajgchouhan commented on Aug 13, 2025

    @gajrajgchouhan

    Still not available as 0.80

  16. react-native-bot commented on Feb 10, 2026

    @react-native-bot
    Collaborator

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  17. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 10, 2026
  18. Clarkkkk commented on Feb 10, 2026

    @Clarkkkk

    Bump. It is still an issue.

  19. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Feb 10, 2026
  20. react-native-bot commented on Aug 10, 2026

    @react-native-bot
    Collaborator

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  21. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Aug 10, 2026
  22. gajrajgchouhan commented on Aug 10, 2026

    @gajrajgchouhan

    Bump. Still an issue.

  23. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions