Skip to content

haskell-miso/miso-fetch

Repository files navigation

🍜 ⚡ miso-fetch

image

Usage

----------------------------------------------------------------------------
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, then:

nix develop .#wasm
make
make serve

About

⚡ An example demonstrating AJAX requests in miso

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published