- From: Domenic Denicola <notifications@github.com>
- Date: Thu, 08 Oct 2015 08:51:18 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
Received on Thursday, 8 October 2015 15:51:57 UTC
> @@ -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(/* … */)</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).")
Optional ES6 goodness: ``log(`received ${value.byteLength} bytes (${total} bytes in total)`)``.
---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/138/files#r41531162
Received on Thursday, 8 October 2015 15:51:57 UTC