Copyright | (c) Moritz Kiefer 2017 |
---|---|
License | BSD3 |
Maintainer | moritz.kiefer@purelyfunctional.org |
Stability | experimental |
Portability | GHCJS |
Safe Haskell | None |
Language | Haskell2010 |
This module provides bindings for JavaScript’s Fetch API.
The bindings deliberately stay close to the JavaScript API so most documentation and tutorials should be easily translatable.
An introduction to the Fetch API can be found at https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch.
- fetch :: Request -> IO JSResponse
- data Request = Request {
- reqUrl :: !JSString
- reqOptions :: !RequestOptions
- data RequestOptions = RequestOptions {}
- defaultRequestOptions :: RequestOptions
- data RequestMode
- = Cors
- | NoCors
- | SameOrigin
- | Navigate
- data RequestCredentials
- data RequestCacheMode
- data RequestRedirectMode
- data RequestReferrer
- responseJSON :: JSResponse -> IO Value
- responseText :: JSResponse -> IO JSString
- data JSPromiseException = JSPromiseException !JSVal
Fetch
fetch :: Request -> IO JSResponse Source #
Throws JSPromiseException
when the request fails.
See https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch.
Request
Request | |
|
data RequestOptions Source #
These options correspond to the init
argument to the Request constructor.
RequestOptions | |
|
defaultRequestOptions :: RequestOptions Source #
Default request options. These correspond to the default options specified in the fetch standard.
data RequestMode Source #
data RequestCredentials Source #
data RequestCacheMode Source #
data RequestRedirectMode Source #
data RequestReferrer Source #
Response
responseJSON :: JSResponse -> IO Value Source #
Throws JSPromiseException
when decoding fails.
See https://developer.mozilla.org/en-US/docs/Web/API/Body/json.
responseText :: JSResponse -> IO JSString Source #
Throws JSPromiseException
when decoding fails.
See https://developer.mozilla.org/en-US/docs/Web/API/Body/text.