Re: [fetch] Add an example using Response body (#138)

> @@ -3082,6 +3082,31 @@ <h4 id="should-response-to-request-be-blocked-due-to-nosniff?"><dfn title="shoul
>      params = {lat:35.696233, long:139.570431}
>  Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
>  fetch(url).then(/* &hellip; */)</pre>
> +
> + <p>If you want to receive the body data progressively:
> +
> + <pre>function consume(reader) {
> +  var total = 0
> +  return new Promise((resolve, reject) => {
> +    function pump() {
> +      reader.read().then(({done, value}) => {
> +        if (done) {
> +          resolve()
> +          return
> +        }
> +        total += value.byteLength
> +        log("received " + value.byteLength + " bytes (" + total + " bytes in total).")

Thanks, done.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/138/files#r41618738

Received on Friday, 9 October 2015 10:56:18 UTC