Skip to content

Commit 6955485

Browse files
committed
README: explain how to interact with HTTP APIs
Still rather minimal...
1 parent 11caf5b commit 6955485

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
- [Internals](#internals)
5151
- [Examples](#examples)
5252
- [Building examples](#building-examples)
53+
- [Coverage](#interacting-with-http-apis)
5354
- [Coverage](#coverage)
5455
- [Isomorphic](#isomorphic)
5556
- [Benchmarks](#benchmarks)
@@ -578,6 +579,23 @@ cd result/bin/todo-mvc.jsexe && http-sever
578579
Serving HTTP on 0.0.0.0 port 8000 ...
579580
```
580581

582+
## Interacting with HTTP APIs 🔌
583+
584+
If you want to interact with an HTTP API, we recommend one of the following approaches:
585+
586+
1. For a simple JSON-based API, you can use Miso's `fetchJSON` function.
587+
588+
2. In more complex cases, you can define a [Servant](https://www.servant.dev/) API and automatically obtain client functions via `servant-client-js` (or any other `servant-client-core`-based backend).
589+
590+
The Fetch example ([Source](https://github.com/dmjio/miso/blob/master/examples/fetch/Main.hs), [Demo](https://fetch.haskell-miso.org/)) demonstrates the necessary ingredients. Make sure to add the following to your `cabal.project`:
591+
592+
```cabal
593+
source-repository-package
594+
type: git
595+
location: https://github.com/amesgen/servant-client-js
596+
tag: 2853fb4f26175f51ae7b9aaf0ec683c45070d06e
597+
```
598+
581599
## Coverage ✅
582600
583601
The core engine of `miso` is the [diff](https://github.com/dmjio/miso/blob/master/ts/dom.ts) function. It is responsible for all DOM manipulation that occurs in a miso application and has [100% code coverage](http://coverage.haskell-miso.org). Tests and coverage made possible using [bun](https://github.com/oven-sh/bun).

0 commit comments

Comments
 (0)