-
Notifications
You must be signed in to change notification settings - Fork 3
Update FetchAPI constructors #103
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
Conversation
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.
Thank you, looks good!
One small nit, I would like to avoid the KV
abbreviation.
src/FetchAPI/HeadersInit.res
Outdated
/** | ||
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#setting_headers) | ||
*/ | ||
external fromKVArray: array<(string, string)> => headersInit = "%identity" |
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.
external fromKVArray: array<(string, string)> => headersInit = "%identity" | |
external fromKeyValueArray: array<(string, string)> => headersInit = "%identity" |
src/FetchAPI/URLSearchParams.res
Outdated
|
||
/** | ||
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | ||
*/ | ||
@new | ||
external make2: (~init: any=?) => urlSearchParams = "URLSearchParams" | ||
external fromKVArray: array<(string, string)> => urlSearchParams = "URLSearchParams" |
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.
external fromKVArray: array<(string, string)> => urlSearchParams = "URLSearchParams" | |
external fromKeyValueArray: array<(string, string)> => urlSearchParams = "URLSearchParams" |
tests/FetchAPI/Headers__test.res
Outdated
|
||
let h2 = Headers.fromDict(dict{"X-Vegetable": "Carrot"}) | ||
|
||
let h3 = Headers.fromKVArray([("X-Fruit", "Apple"), ("X-Vegetable", "Carrot")]) |
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.
let h3 = Headers.fromKVArray([("X-Fruit", "Apple"), ("X-Vegetable", "Carrot")]) | |
let h3 = Headers.fromKeyValueArray([("X-Fruit", "Apple"), ("X-Vegetable", "Carrot")]) |
params1->URLSearchParams.keys->Iterator.toArray->Array.forEach(Console.log) | ||
|
||
let params2 = URLSearchParams.make3(~init="?foo=1&bar=b") | ||
let params2 = URLSearchParams.fromKVArray([("foo", "1"), ("bar", "b")]) |
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.
let params2 = URLSearchParams.fromKVArray([("foo", "1"), ("bar", "b")]) | |
let params2 = URLSearchParams.fromKeyValueArray([("foo", "1"), ("bar", "b")]) |
Thanks for your suggestion! |
How is |
Hmm, you are suggesting to maybe reuse |
No description provided.