-
Notifications
You must be signed in to change notification settings - Fork 15
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
Allow custom fetch
function to be provided
#1646
Conversation
/** | ||
* Custom `fetch` function | ||
*/ | ||
fetch?: typeof crossFetch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is the right type or I should just use any
(for example https://github.com/octokit/request.js allows you to pass a custom fetch
function but types it as any
: https://github.com/octokit/types.ts/blob/b21cc042affd15918abdc0636cb017e3751bbadc/src/Fetch.ts) because the Node fetch and browser fetch types aren't fully compatible: nodejs/undici#1943
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, any
sounds a little safer to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! Feel free to push edits to this PR directly if you have edit rights
@skarimo, @HantingZhang2, apologies for the direct ping but could you review this PR when you get a chance please? |
cc @therve |
@NMinhNguyen 👋 We will review this soon and follow up. |
* Allow custom `fetch` function to be provided * Switch type to any. * Fix test. * Fix test. --------- Co-authored-by: Hanting ZHANG <42933443+HantingZhang2@users.noreply.github.com> Co-authored-by: Jack Edmonds <jack.edmonds@datadoghq.com> c09810e
@jack-edmonds-dd thanks a lot for the updates and merging the PR! Roughly when can we expect a new release to be published? |
Probably early next week. |
What does this PR do?
This PR allows a custom
fetch
function to be provided. This makes it a lot easier to add proxy support without having to copy the implementation (and remember to keep it up-to-date) ofIsomorphicFetchHttpLibrary
along with all of its dependencies:datadog-api-client-typescript/packages/datadog-api-client-common/http/isomorphic-fetch.ts
Lines 1 to 11 in 16cf2b7
Example usage:
Additional Notes
Review checklist
Please check relevant items below:
This PR includes all newly recorded cassettes for any modified tests.
This PR does not rely on API client schema changes.
Or, this PR relies on API schema changes and this is a Draft PR to include tests for that new functionality.