Re: [whatwg] Fetch API Polyfill

2014-10-14 Thread David Graham
Interesting—thanks for the clarification. I've updated the example from this

fetch('/users.html').then(function(response) {
  document.body.innerHTML = response.body
})

to this

fetch('/users.html')
  .then(function(response) {
return response.text()
  }).then(function(body) {
document.body.innerHTML = body
  })

Should `response.body` ever be used directly or only accessed through
one of the response body promises (json, text, blob, arrayBuffer,
formData)?

On Tue, Oct 14, 2014 at 4:03 AM, Anne van Kesteren ann...@annevk.nl wrote:
 On Tue, Oct 14, 2014 at 1:15 AM, David Graham
 david.malcom.gra...@gmail.com wrote:
 We’re developing a polyfill for the new Fetch API at GitHub:

https://github.com/github/fetch

 The spec was fairly easy to follow, but I’d love any feedback on places the 
 implementation could be improved. Fetch is probably the most exciting new 
 browser API since querySelectorAll.

 The example in README.md suggests your promise resolves too late. It
 needs to resolve when all the HTTP headers are in. The body can then
 be accessed through a series of promise methods. (And in the future
 you can have access to a stream at that point as well.)


 --
 https://annevankesteren.nl/


Re: [whatwg] Fetch API Polyfill

2014-10-14 Thread Anne van Kesteren
On Tue, Oct 14, 2014 at 6:08 PM, David Graham
david.malcom.gra...@gmail.com wrote:
 Interesting—thanks for the clarification. I've updated the example from this

 fetch('/users.html').then(function(response) {
   document.body.innerHTML = response.body
 })

 to this

 fetch('/users.html')
   .then(function(response) {
 return response.text()
   }).then(function(body) {
 document.body.innerHTML = body
   })

That looks good.


 Should `response.body` ever be used directly or only accessed through
 one of the response body promises (json, text, blob, arrayBuffer,
 formData)?

At the moment there is no member named body (it was recently
removed). It will likely return in the future once
https://streams.spec.whatwg.org/ is stable enough.


-- 
https://annevankesteren.nl/