melange-community / melange-fetch

Fetch bindings for Melange
MIT License
203 stars 53 forks source link

Fix signature for Headers append and delete #28

Closed yihangho closed 5 years ago

yihangho commented 5 years ago

It seems that the signatures for Headers.append & .delete are wrong. Previously, there were:

external append : string -> string = "" [@@bs.send.pipe: t]
external delete : string = "" [@@bs.send.pipe: t]

However, their usage (in JS) should be

headers.append("Content-Type", "application/json");
headers.delete("Content-Type");

So I think there should be an extra -> unit for both of them.

I've tested my fix with the following (in Reason):

let headers = Fetch.Headers.make;
Fetch.Headers.append("X-My-Header", "value", headers);
Fetch.Headers.delete("X-My-Header", headers);

and the corresponding generated JS (sans extra spacing for readability):

'use strict';
var headers = new Headers();
headers.append("X-My-Header", "value");
headers.delete("X-My-Header");