diff --git a/src/DOMAPI/Window.js b/src/DOMAPI/Window.js index 977be07..dbf8d92 100644 --- a/src/DOMAPI/Window.js +++ b/src/DOMAPI/Window.js @@ -1,7 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as EventTarget$WebApi from "../EventAPI/EventTarget.js"; +import * as EventTarget$WebAPI from "../EventAPI/EventTarget.js"; -EventTarget$WebApi.Impl({}); +EventTarget$WebAPI.Impl({}); /* Not a pure module */ diff --git a/src/DOMAPI/Window.res b/src/DOMAPI/Window.res index ce403a2..fdca408 100644 --- a/src/DOMAPI/Window.res +++ b/src/DOMAPI/Window.res @@ -294,16 +294,33 @@ external structuredClone: (window, 't, ~options: structuredSerializeOptions=?) = "structuredClone" /** +`fetch(window, string, init)` + +Starts the process of fetching a resource from the network, +returning a promise that is fulfilled once the response is available. + +```res +let response = await window->Window.fetch("https://rescript-lang.org") +``` + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ @send -external fetch: (window, ~input: request, ~init: requestInit=?) => Promise.t = "fetch" +external fetch: (window, string, ~init: requestInit=?) => Promise.t = "fetch" /** +`fetch_withRequest(window, request, init)` + +Starts the process of fetching a resource from the network, +returning a promise that is fulfilled once the response is available. + +```res +let response = await window->Window.fetch(myRequest) +``` [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ @send -external fetch2: (window, ~input: string, ~init: requestInit=?) => Promise.t = "fetch" +external fetch_withRequest: (window, request, ~init: requestInit=?) => Promise.t = "fetch" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame) diff --git a/src/Global.res b/src/Global.res index f1932ae..a5b6e66 100644 --- a/src/Global.res +++ b/src/Global.res @@ -480,14 +480,33 @@ external createImageBitmap18: ( external structuredClone: ('t, ~options: structuredSerializeOptions=?) => 't = "structuredClone" /** +`fetch(string, init)` + +Starts the process of fetching a resource from the network, +returning a promise that is fulfilled once the response is available. + +```res +let response = await fetch("https://rescript-lang.org") +``` + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ -external fetch: (~input: request, ~init: requestInit=?) => Promise.t = "fetch" +external fetch: (string, ~init: requestInit=?) => Promise.t = "fetch" /** +`fetch_withRequest(request, init)` + +Starts the process of fetching a resource from the network, +returning a promise that is fulfilled once the response is available. + +```res +let response = await fetch(myRequest) +``` + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ -external fetch2: (~input: string, ~init: requestInit=?) => Promise.t = "fetch" +@send +external fetch_withRequest: (request, ~init: requestInit=?) => Promise.t = "fetch" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame) diff --git a/tests/Global__test.js b/tests/Global__test.js new file mode 100644 index 0000000..9a955dc --- /dev/null +++ b/tests/Global__test.js @@ -0,0 +1,9 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + + +let response = await fetch("https://rescript-lang.org/"); + +export { + response, +} +/* response Not a pure module */ diff --git a/tests/Global__test.res b/tests/Global__test.res new file mode 100644 index 0000000..ff4525e --- /dev/null +++ b/tests/Global__test.res @@ -0,0 +1,3 @@ +open WebAPI.Global + +let response = await fetch("https://rescript-lang.org/")