Copyright | (c) Moritz Kiefer 2017 |
---|---|
License | BSD3 |
Maintainer | moritz.kiefer@purelyfunctional.org |
Stability | experimental |
Portability | GHCJS |
Safe Haskell | None |
Language | Haskell2010 |
GHCJS.Fetch
Contents
Description
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
Constructors
Request | |
Fields
|
data RequestOptions Source #
These options correspond to the init
argument to the Request constructor.
Constructors
RequestOptions | |
Fields
|
Instances
defaultRequestOptions :: RequestOptions Source #
Default request options. These correspond to the default options specified in the fetch standard.
data RequestCredentials Source #
Constructors
CredOmit | |
CredSameOrigin | |
CredInclude |
data RequestCacheMode Source #
Constructors
CacheDefault | |
NoStore | |
Reload | |
NoCache | |
ForceCache | |
OnlyIfCached |
data RequestRedirectMode Source #
data RequestReferrer Source #
Constructors
NoReferrer | |
Client | |
ReferrerUrl !JSString |
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.