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
- Host: GitHub
- URL: https://github.com/haskell-miso/miso-fetch
- Owner: haskell-miso
- Created: 2025-07-26T14:07:27.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-09-07T02:07:15.000Z (5 months ago)
- Last Synced: 2025-09-07T03:27:35.356Z (5 months ago)
- Topics: ajax, fetch, fetch-api, haskell, miso
- Language: Haskell
- Homepage: https://fetch.haskell-miso.org/
- Size: 61.5 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# :ramen: ⚡ miso-fetch
### 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
```