An open API service indexing awesome lists of open source software.

https://github.com/haskell-miso/miso-fetch

⚡ An example demonstrating AJAX requests in miso
https://github.com/haskell-miso/miso-fetch

ajax fetch fetch-api haskell miso

Last synced: 4 months ago
JSON representation

⚡ An example demonstrating AJAX requests in miso

Awesome Lists containing this project

README

          

# :ramen: ⚡ miso-fetch


image

### Usage

```haskell
----------------------------------------------------------------------------
data Action
= FetchGitHub
| SetGitHub (Response GitHub)
| ErrorHandler (Response MisoString)
----------------------------------------------------------------------------
app :: App Model Action
app = component emptyModel updateModel viewModel
----------------------------------------------------------------------------
updateModel :: Action -> Transition Model Action
updateModel = \case
FetchGitHub ->
getJSON "https://api.github.com" [] SetGitHub ErrorHandler
SetGitHub Response {..} ->
info ?= body
ErrorHandler Response {..} ->
io_ (consoleError body)
----------------------------------------------------------------------------
```

## Build and run

Install [Nix Flakes](https://nixos.wiki/wiki/Flakes), then:

```
nix develop .#wasm
make
make serve
```