Zero-cost rescript bindings to the WHATWG Fetch API
Example
let postBanana = async data => { open Fetch let response = await fetch( "/api/bananas", { method: #POST, body: data->JSON.stringifyAny->Option.getOrThrow->Body.string, headers: Headers.fromObject({ "Content-type": "application/json", }), }, ) await response->Response.json }
See examples for more.
Installation
npm install --save @glennsl/rescript-fetch
Then add @glennsl/rescript-fetch to dependencies in your rescript.json:
{
"dependencies": [
+ "@glennsl/rescript-fetch"
]
}Documentation
API
For the moment, please see the interface file:
Changes
0.3.0
- [BREAKING] Updated required minimum version of rescript to 12.
- Replaced
bsconfig.jsonwithrescript.jsonand switched module spec toesmodule. - Migrated from
Js.Json.t/Js.Array.array_liketo the rescript 12 standard library (JSON.t,Iterator.t).
0.2.3
- Added
Headers.getSetCookie
0.2.2
- Fixed typo in
Request.credentialsbinding.
0.2.1
- Fleshed out
AbortSignalbindings.
0.2.0
- [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-promisedependency.
0.1.0
Initial release