Zero-cost rescript bindings to the WHATWG Fetch API
npm install @glennsl/rescript-fetch


``rescript
let postBanana = async data => {
open Fetch
let response = await fetch(
"/api/bananas",
{
method: #POST,
body: data->Js.Json.stringifyAny->Belt.Option.getExn->Body.string,
headers: Headers.fromObject({
"Content-type": "application/json",
}),
},
)
await response->Response.json
}
`
See examples for more.
`sh`
npm install --save @glennsl/rescript-fetch
Then add @glennsl/rescript-fetch to bs-dependencies in your bsconfig.json:
`diff`
{
"bs-dependencies": [
+ "@glennsl/rescript-fetch"
]
}
For the moment, please see the interface file:
* Fetch
* Added Headers.getSetCookie
* Fixed typo in Request.credentials binding.
* Fleshed out AbortSignal bindings.
* [BREAKING] Updated required minimum version of rescript to 10.1.2 in order to use the new promise type alias and async/await.
* Removed @ryyppy/rescript-promise` dependency.