Open pkieltyka opened 4 years ago
I spent some more time reading the README and source, and seems like you made a conscious decision to use the node readablestream api over whatwg. Two questions..
Hi there, first I want to thank you for making this! finally a quality fetch implementation for nodejs :) Please let me know if you are accepting sponsorship, I'm happy to support!
secondly, what's your opinion on getting to api parity with the fetch spec? my personal use case is to having javascript clients that can be used in both nodejs and in browsers, I've achieved this in github.com/webrpc/webrpc example: https://github.com/webrpc/webrpc/blob/master/_examples/hello-webrpc-ts/webapp/src/client.gen.ts .. but now I am adding http streaming support to webrpc and I'd like the JS client to use identical code for node and browsers for simplicity.
Sadly, every fetch implementation for node fails to implement the readable streams with a consistent api as browsers.
example:
const consume = responseReader => { return responseReader.read().then(result => { if (result.done) { return; } // do something with the current chunk const chunk = result.value; return consume(responseReader); }); } // Perform the request and consume response stream fetch(url).then(response => { return consume(response.body.getReader()); }) .catch(console.log.bind(console));
dit you manage to figure this out? I am working on a streaming grpc lib and I am also running into the issue of the API's not being compatible
Hi there, first I want to thank you for making this! finally a quality fetch implementation for nodejs :) Please let me know if you are accepting sponsorship, I'm happy to support!
secondly, what's your opinion on getting to api parity with the fetch spec? my personal use case is to having javascript clients that can be used in both nodejs and in browsers, I've achieved this in github.com/webrpc/webrpc example: https://github.com/webrpc/webrpc/blob/master/_examples/hello-webrpc-ts/webapp/src/client.gen.ts .. but now I am adding http streaming support to webrpc and I'd like the JS client to use identical code for node and browsers for simplicity.
Sadly, every fetch implementation for node fails to implement the readable streams with a consistent api as browsers.
example: