react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Fetch Streaming Body

Open ambarc opened this issue 10 years ago • 7 comments

Question about RN's fetch API spec vs the Web Spec.

For reading a JSON stream through a browser - something like this works:

fetch(url).then(response => {
  const reader = response.body.getReader();
  const decoder = new TextDecoder();

  reader.read().then(function process(result) {
    if (result.done) return;
    const text = decoder.decode(result.value, {stream: true});
    console.log(text);
    return reader.read().then(process);
  }).then(() => {
    console.log('All done!');
  });
});

However, in RN - response.body returns as undefined. Is this missing in RN's fetch spec? Is there an alternative to consume the partial stream?

ambarc avatar Aug 29 '16 04:08 ambarc

@vjeux sorry to page. Does React Native's fetch implementation support streaming?

ambarc avatar Sep 01 '16 20:09 ambarc

@facebook-github-bot label Icebox

charpeni avatar Nov 14 '16 01:11 charpeni

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/fetch-streaming-body

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

charpeni avatar Nov 14 '16 01:11 charpeni

@facebook-github-bot close

charpeni avatar Nov 14 '16 01:11 charpeni

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

facebook-github-bot avatar Nov 14 '16 01:11 facebook-github-bot

This question resolved or have a plan now? Steam feature is good for download file process.

yuyao110120 avatar Jan 18 '18 03:01 yuyao110120

ended up using websockets.

ambarc avatar Jan 18 '18 21:01 ambarc