-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: use with fetch API #341
Comments
In the meantime, |
Hi @jamesarosen, thank's for the suggestions, we will take a look what is the best way to implement the solution when we will have enough capacity, but any thoughts, discussions and PRs are welcome! |
I think the simplest thing would be to add an optional import { RestClient, FetchBasedHttpClient } from "typed-rest-client";
const myApi = new RestClient({ client: new FetchBasedHttpClient() }); That would require adding an optional package dependency on either Another alternative would be a separate package like |
This issue has had no activity in 90 days. Please comment if it is not actually stale |
This issue has had no activity in 90 days. Please comment if it is not actually stale |
Environment
Node version: 18.x
typed-rest-client version: 1.8.11
Issue Description
Popular libraries like make-fetch-happen and cache-control-fetch rely on the
fetch
API. This API is new in Node 18, but has good polyfill support through node-fetch or minipass-fetch.It is currently possible to override
RestClient.client.requestRawWithCallback
to usefetch
, but the method is complex and the interface betweenfetch/Request/Response
andhttp/ClientRequest/IncomingMessage
is nuanced. I'd love to see a standard (and well-tested!) community solution for this so we can all get the implementation right.The text was updated successfully, but these errors were encountered: