W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2014

Re: [whatwg] Questions about the Fetch API

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Thu, 10 Jul 2014 19:05:47 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>, Juan Ignacio Dopazo <jdopazo@yahoo-inc.com>
Message-ID: <1405019146501.89483@domenicdenicola.com>
Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>
From: whatwg <whatwg-bounces@lists.whatwg.org> on behalf of Juan Ignacio Dopazo <jdopazo@yahoo-inc.com>

> Would it be to crazy to get fetch(url).asJSON() to work? Either by not having fetch() return a promise (and return something that has a function that returns a promise for the headers) or by having it return a subclass of Promise that contains those utility methods?

In my opinion subclassing promises should not be done just for adding minor conveniences. It should be done for qualitatively new types of promises (e.g. cancellable ones), but arbitrary concepts should not become promise subclasses.

> Also, my question about the Request class is because I don't see a way to get a writable stream for the body of the request. It'd be nice if we had that for uploaders for example.

This is a very important question and we should look into solving it before the API settles too much.

To provide a clearer example of what Juan is talking about, in Node it is common to do something like


var req = http.request({ method: "POST", ... });

req.write("data1");
req.write("data2");
req.end();

// or even better

fs.createReadStream("file.txt").pipe(req);

We are doing a very good job IMO on preparing the spec for readable stream integration, with the FetchBodyStream scaffold. We need to spend similar effort preparing for writable stream integration. I would be happy to help spearhead this effort along with anyone else interested.

Received on Thursday, 10 July 2014 19:06:33 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:21 UTC