TheSpyder / rescript-webapi

ReScript bindings to the DOM and other Web APIs
http://tinymce.github.io/rescript-webapi/api/Webapi/
Other
151 stars 37 forks source link

Passing `Headers.t` to `RequestInit.make` and `Request.t` to `fetch` #70

Open tom-sherman opened 2 years ago

tom-sherman commented 2 years ago

I'm not sure about how this would be done but it would be great if I could pass Headers.t to RequestInit.make and Request.t to fetch.

This is possible in the fetch API but not possible in the bindings right now.

My current workaround is to have a couple of cast functions. This function is safe for Request as it extends RequestInit so it's safe to downcast it, it's unsafe for Headers though except for the fetch API.

TheSpyder commented 2 years ago

That headers change is the first thing I did in #30 😂 https://github.com/tinymce/rescript-webapi/compare/fetch-newapi

Supplying a Request.t to fetch also makes sense, similar to how I changed the headers, forcing use of the init object doesn't make a lot of sense to me.