- From: bORm <notifications@github.com>
- Date: Fri, 16 Sep 2016 10:35:34 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
Received on Friday, 16 September 2016 17:36:09 UTC
https://github.com/whatwg/fetch/issues/21
Okay, **Fetch API integrated with Streams** it`s really cool, but
from https://fetch.spec.whatwg.org/#fetch-api
```
function consume(response, total=0) {
var reader = response.body.getReader()
return pump()
function pump() {
return reader.read().then(({done, value}) => {
if (done) {
return response
}
total += value.byteLength
log(`received ${value.byteLength} bytes (${total} bytes in total)`)
return pump()
})
}
}
fetch("/music/pk/altes-kamuffel.flac", {method: 'POST', body: MYFormData})
.then(response => consume(response))
.then(response => return response.json() // "Already read" )
.then((resultFromServer) => log(resultFromServer.file))
.catch(e => log("something went wrong: " + e))
```
how return real response.json() from Server?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/389
Received on Friday, 16 September 2016 17:36:09 UTC