https://github.com/glennsl/rescript-fetch
Zero-cost rescript bindings to the WHATWG Fetch API
https://github.com/glennsl/rescript-fetch
fetch rescript
Last synced: about 2 months ago
JSON representation
Zero-cost rescript bindings to the WHATWG Fetch API
- Host: GitHub
- URL: https://github.com/glennsl/rescript-fetch
- Owner: glennsl
- License: mit
- Created: 2022-08-06T20:08:23.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-11-30T08:52:58.000Z (over 1 year ago)
- Last Synced: 2025-10-19T16:10:06.109Z (5 months ago)
- Topics: fetch, rescript
- Language: ReScript
- Homepage:
- Size: 38.1 KB
- Stars: 61
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rescript-fetch
Zero-cost rescript bindings to the WHATWG Fetch API
[](https://npmjs.org/@glennsl/rescript-fetch)
[](https://github.com/glennsl/rescript-fetch/issues)
[](https://github.com/glennsl/rescript-fetch/commits/master)
## Example
```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](https://github.com/glennsl/rescript-fetch/blob/master/examples/) for more.
## Installation
```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"
]
}
```
## Documentation
### API
For the moment, please see the interface file:
* [Fetch](https://github.com/glennsl/rescript-fetch/blob/master/src/Fetch.res)
## Changes
### 0.2.3
* Added `Headers.getSetCookie`
### 0.2.2
* Fixed typo in `Request.credentials` binding.
### 0.2.1
* Fleshed out `AbortSignal` bindings.
### 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-promise` dependency.
### 0.1.0
Initial release