Copyright | (C) 2016-2025 David M. Johnson |
---|---|
License | BSD3-style (see the file LICENSE) |
Maintainer | David M. Johnson <code@dmj.io> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Miso.Fetch
Description
Module for interacting with the Fetch API https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API manually.
Refer to the miso README if you want to automatically interact with a Servant API.
Synopsis
- getJSON :: FromJSON result => MisoString -> [(MisoString, MisoString)] -> (result -> action) -> (MisoString -> action) -> Effect parent model action
- postJSON :: ToJSON body => MisoString -> body -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- putJSON :: ToJSON body => MisoString -> body -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- getText :: MisoString -> [(MisoString, MisoString)] -> (MisoString -> action) -> (MisoString -> action) -> Effect parent model action
- postText :: MisoString -> MisoString -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- putText :: MisoString -> MisoString -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- getBlob :: MisoString -> [(MisoString, MisoString)] -> (Blob -> action) -> (MisoString -> action) -> Effect parent model action
- postBlob :: MisoString -> Blob -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- putBlob :: MisoString -> Blob -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- postImage :: MisoString -> Image -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- putImage :: MisoString -> Image -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- getArrayBuffer :: MisoString -> [(MisoString, MisoString)] -> (ArrayBuffer -> action) -> (MisoString -> action) -> Effect parent model action
- postArrayBuffer :: MisoString -> ArrayBuffer -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- putArrayBuffer :: MisoString -> ArrayBuffer -> [(MisoString, MisoString)] -> action -> (MisoString -> action) -> Effect parent model action
- accept :: MisoString
- contentType :: MisoString
- applicationJSON :: MisoString
- type Body = JSVal
JSON
Arguments
:: FromJSON result | |
=> MisoString | url |
-> [(MisoString, MisoString)] | headers |
-> (result -> action) | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
data Action = FetchGitHub | SetGitHub GitHub | ErrorHandler MisoString deriving (Show, Eq) updateModel :: Action -> Effect Model Action updateModel FetchGitHub = getJSON "https://api.github.com" [] SetGitHub ErrorHandler updateModel (SetGitHub apiInfo) = info ?= apiInfo updateModel (ErrorHandler msg) = io_ (consoleError msg)
Arguments
:: ToJSON body | |
=> MisoString | url |
-> body | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: ToJSON body | |
=> MisoString | url |
-> body | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Text
Arguments
:: MisoString | url |
-> [(MisoString, MisoString)] | headers |
-> (MisoString -> action) | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> MisoString | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> MisoString | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Blob
Arguments
:: MisoString | url |
-> [(MisoString, MisoString)] | headers |
-> (Blob -> action) | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> Blob | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> Blob | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Image
Arguments
:: MisoString | url |
-> Image | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> Image | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
ArrayBuffer
Arguments
:: MisoString | url |
-> [(MisoString, MisoString)] | headers |
-> (ArrayBuffer -> action) | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> ArrayBuffer | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Arguments
:: MisoString | url |
-> ArrayBuffer | Body |
-> [(MisoString, MisoString)] | headers |
-> action | successful callback |
-> (MisoString -> action) | errorful callback |
-> Effect parent model action |
Header helpers
accept :: MisoString Source #