Zero-cost rescript bindings to the WHATWG Fetch API
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.
npm install --save @glennsl/rescript-fetch
Then add @glennsl/rescript-fetch
to bs-dependencies
in your bsconfig.json
:
{
"bs-dependencies": [
+ "@glennsl/rescript-fetch"
]
}
For the moment, please see the interface file:
- 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.
Initial release