-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add fetch option #214
Add fetch option #214
Conversation
Related to: #207 |
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.
Code-wise, this looks great, but we should NOT merge this into the main code-base until we have some major users test it out first. We had issues previously with dynamically required libraries, and I only want to prerelease
this until we do thorough testing.
NO MERGE YET.
@danieltodonnell the dynamic requires was solved. We are already doing that on Line 86 in 1901da3
|
I can do some debugging on this myself, and let you know if it works well or not! |
@lolcoolkat I would love that. Thanks! |
So I got it working inside my Cloudflare Worker by doing the following:
Note: Passing The only problem was that there seem's to be an issue with the following code, which gives me a Line 189 in 1901da3
Removing this line makes the FaunaDB client work fine again :) (However i'm sure that it definitely does something important :P) |
Thanks @lolcoolkat for the help on this.
|
I am also trying to get this working on cloudflare workers so I happen to have some answers:
(Or whatever the accepted way of iteration is in ES5, I assume we can't |
Thank you @mpavlinsky !! Doing the following:
seem's to do the trick! And for your # 2 that info is helpful. Thanks! |
@mpavlinsky do you know if there is any doc related to the |
https://developers.cloudflare.com/workers/reference/apis/fetch/ Regarding the headers I think that is the behavior of the standard fetch. In my browser console |
Use response.headers as Headers object like Web API specifies: https://developer.mozilla.org/en-US/docs/Web/API/Headers
@lolcoolkat @mpavlinsky can you check if the last commit fixes the |
Works perfectly! Thanks for the fix :) |
test('uses custom fetch', async function() { | ||
const fetch = jest.fn(() => | ||
Promise.resolve({ | ||
headers: new Set(), |
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 believe we want a test that exercises headers as an Iterator
as is the case when using browser fetch
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.
The Iterator
is returned by the entries()
. The headers
options are type of Headers[]
which have a similar API with the Headers
object. I used Set()
to avoid extra mocking.
Headers ref: https://developer.mozilla.org/en-US/docs/Web/API/Headers/Headers
Beta version published on https://www.npmjs.com/package/faunadb/v/2.11.2-beta |
No description provided.