Module

Simple.Ajax

#simpleRequest

simpleRequest :: forall a b r rx t. EncodeJson a => DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Either Method CustomMethod -> Record r -> URL -> Maybe a -> Aff (Either AjaxError b)

Makes an HTTP request and tries to parse the response json.

Helper methods are provided for the most common requests.

#simpleRequest_

simpleRequest_ :: forall a r rx t. EncodeJson a => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Either Method CustomMethod -> Record r -> URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes an HTTP request ignoring the response payload.

Helper methods are provided for the most common requests.

#SimpleRequest

type SimpleRequest = Record SimpleRequestRow

A Request object with only the allowed fields.

#SimpleRequestRow

type SimpleRequestRow = (headers :: Array RequestHeader, password :: Maybe String, username :: Maybe String, withCredentials :: Boolean)

#postR

postR :: forall a b r rx t. EncodeJson a => DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either AjaxError b)

Makes a POST request, taking a subset of a SimpleRequest, an URL and an optional payload and then tries to parse the response json.

#post

post :: forall a b. EncodeJson a => DecodeJson b => URL -> Maybe a -> Aff (Either AjaxError b)

Makes a POST request, taking an URL and an optional payload trying to parse the response json.

#postR_

postR_ :: forall a r rx t. EncodeJson a => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a POST request, taking a subset of a SimpleRequest, an URL and an optional payload, ignoring the response payload.

#post_

post_ :: forall a. EncodeJson a => URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a POST request, taking an URL and an optional payload, ignoring the response payload.

#postH

postH :: forall a b. EncodeJson a => DecodeJson b => URL -> Maybe a -> Aff (Either AjaxError (Tuple (Array ResponseHeader) b))

Makes a POST request, taking an URL and an optional payload trying to parse the response json.

#postH_

postH_ :: forall a. EncodeJson a => URL -> Maybe a -> Aff (Either HTTPError (Tuple (Array ResponseHeader) Unit))

Makes a POST request, taking an URL and an optional payload, ignoring the response payload.

#postRH

postRH :: forall a b r rx t. EncodeJson a => DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either AjaxError (Tuple (Array ResponseHeader) b))

Makes a POST request, taking a subset of a SimpleRequest, an URL and an optional payload and then tries to parse the response json, and provides the response headers.

#postRH_

postRH_ :: forall a r rx t. EncodeJson a => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either HTTPError (Tuple (Array ResponseHeader) Unit))

Makes a POST request, taking a subset of a SimpleRequest, an URL and an optional payload, ignoring the response payload.

#putR

putR :: forall a b r rx t. EncodeJson a => DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either AjaxError b)

Makes a PUT request, taking a subset of a SimpleRequest, an URL and an optional payload and then tries to parse the response json.

#put

put :: forall a b. EncodeJson a => DecodeJson b => URL -> Maybe a -> Aff (Either AjaxError b)

Makes a PUT request, taking an URL and an optional payload trying to parse the response json.

#putR_

putR_ :: forall a r rx t. EncodeJson a => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a PUT request, taking a subset of a SimpleRequest, an URL and an optional payload, ignoring the response payload.

#put_

put_ :: forall a. EncodeJson a => URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a PUT request, taking an URL and an optional payload, ignoring the response payload.

#deleteR

deleteR :: forall b r rx t. DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Aff (Either AjaxError b)

Makes a DELETE request, taking a subset of a SimpleRequest and an URL and then tries to parse the response json.

#delete

delete :: forall b. DecodeJson b => URL -> Aff (Either AjaxError b)

Makes a DELETE request, taking an URL and then tries to parse the response json.

#deleteR_

deleteR_ :: forall r rx t. Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Aff (Either HTTPError Unit)

Makes a DELETE request, taking a subset of a SimpleRequest and an URL, ignoring the response payload.

#delete_

delete_ :: URL -> Aff (Either HTTPError Unit)

Makes a DELETE request, taking an URL, ignoring the response payload.

#patchR

patchR :: forall a b r rx t. EncodeJson a => DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either AjaxError b)

Makes a PATCH request, taking a subset of a SimpleRequest, an URL and an optional payload and then tries to parse the response json.

#patch

patch :: forall a b. EncodeJson a => DecodeJson b => URL -> Maybe a -> Aff (Either AjaxError b)

Makes a PATCH request, taking an URL and an optional payload trying to parse the response json.

#patchR_

patchR_ :: forall a r rx t. EncodeJson a => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a PATCH request, taking a subset of a SimpleRequest, an URL and an optional payload, ignoring the response payload.

#patch_

patch_ :: forall a. EncodeJson a => URL -> Maybe a -> Aff (Either HTTPError Unit)

Makes a PATCH request, taking an URL and an optional payload, ignoring the response payload.

#getR

getR :: forall b r rx t. DecodeJson b => Union r SimpleRequestRow rx => Union r (RequestRow Json) t => Nub rx SimpleRequestRow => Nub t (RequestRow Json) => Record r -> URL -> Aff (Either AjaxError b)

Makes a GET request, taking a subset of a SimpleRequest and an URL as arguments and then tries to parse the response json.

#get

get :: forall b. DecodeJson b => URL -> Aff (Either AjaxError b)

Makes a GET request, taking an URL as argument and then tries to parse the response json.

#handleResponse

Re-exports from Simple.Ajax.Errors

#HTTPError

type HTTPError = BasicError ()

Basic error type containing the common http errors.

#AjaxError

type AjaxError = BasicError ParseError

Extends HTTPError to add json parsing errors.

#mapBasicError

#_unAuthorized

_unAuthorized :: Proxy @Symbol "unAuthorized"

#_serverError

_serverError :: Proxy @Symbol "serverError"

#_parseError

_parseError :: Proxy @Symbol "parseError"

#_notFound

_notFound :: Proxy @Symbol "notFound"

#_methodNotAllowed

_methodNotAllowed :: Proxy @Symbol "methodNotAllowed"

#_forbidden

_forbidden :: Proxy @Symbol "forbidden"

#_badRequest

_badRequest :: Proxy @Symbol "badRequest"

#_affjaxError

_affjaxError :: Proxy @Symbol "affjaxError"

Modules