https://github.com/reazen/relude-fetch
Relude interop library for the fetch API
https://github.com/reazen/relude-fetch
Last synced: 8 months ago
JSON representation
Relude interop library for the fetch API
- Host: GitHub
- URL: https://github.com/reazen/relude-fetch
- Owner: reazen
- License: mit
- Created: 2019-04-27T03:37:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-12T00:39:19.000Z (about 2 years ago)
- Last Synced: 2025-04-21T13:19:14.516Z (9 months ago)
- Language: Reason
- Size: 241 KB
- Stars: 24
- Watchers: 5
- Forks: 8
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - relude-fetch
README
# relude-fetch
[](https://github.com/reazen/relude-fetch/actions)
[](https://www.npmjs.com/package/relude-fetch)
## Overview
[Relude](https://github.com/reazen/relude) interop library for the Browser
[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
This can also be used in Node.js using a polyfill like
[isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
This library basically wraps the
[bs-fetch](https://github.com/reasonml-community/bs-fetch) Bucklescript library
to lift any publicly-exposed `Js.Promise.t('a)` values into `Relude.IO.t('a,
Js.Promise.error)` values. Using `IO` rather than `Promise` makes error
handling 100% more explicit, allows for better composability with other
effect and error types, and unlocks the full power of monads!
## Examples
See the [tests](https://github.com/reazen/relude-fetch/blob/master/__tests__/ReludeFetch_test.re) for example usage.
Also see the [demo](https://github.com/reazen/relude-fetch/blob/master/examples/demo) for real-world usage, such as file uploads.
## Developer info
### Installation
Dependencies of this library are listed as `peerDepenencies` to avoid issues with multiple version
errors with npm's installation methodology combined with BuckleScript.
```
> npm install --save bs-bastet relude bs-fetch relude-fetch
# Add bs-bastet, relude, bs-fetch, and relude-fetch to your bsconfig.json
```
### Scripts
```
# Normal development scripts
> npm run clean
> npm run build
> npm run cleanbuild
> npm run test
> npm run cleantest
> npm run watch
# Run the demo project via parcel
> npm run demo
```
### Publishing to npm
```
> npm version major|minor|patch
> git push origin --follow-tags
> git push upstream --follow-tags
> npm publish
```
### NixOS
```
> nix-shell
%nix%> npm install
```