Module

Simple.Ajax

Package
purescript-simple-ajax
Repository
dariooddenino/purescript-simple-ajax

#simpleRequest Source

simpleRequest :: forall a b r rx t. WriteForeign a => ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

simpleRequest_ :: forall a r rx t. WriteForeign a => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

type SimpleRequest = Record SimpleRequestRow

A Request object with only the allowed fields.

#SimpleRequestRow Source

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

#postR Source

postR :: forall a b r rx t. WriteForeign a => ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

post :: forall a b. WriteForeign a => ReadForeign 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_ Source

postR_ :: forall a r rx t. WriteForeign a => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

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

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

#postH Source

postH :: forall a b. WriteForeign a => ReadForeign 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_ Source

postH_ :: forall a. WriteForeign 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 Source

postRH :: forall a b r rx t. WriteForeign a => ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

postRH_ :: forall a r rx t. WriteForeign a => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

putR :: forall a b r rx t. WriteForeign a => ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

put :: forall a b. WriteForeign a => ReadForeign 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_ Source

putR_ :: forall a r rx t. WriteForeign a => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

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

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

#deleteR Source

deleteR :: forall b r rx t. ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

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

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

#deleteR_ Source

deleteR_ :: forall r rx t. Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

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

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

#patchR Source

patchR :: forall a b r rx t. WriteForeign a => ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

patch :: forall a b. WriteForeign a => ReadForeign 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_ Source

patchR_ :: forall a r rx t. WriteForeign a => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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_ Source

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

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

#getR Source

getR :: forall b r rx t. ReadForeign b => Union r SimpleRequestRow rx => Union r (RequestRow String) t => Nub rx SimpleRequestRow => Nub t (RequestRow String) => 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 Source

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

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

Re-exports from Simple.Ajax.Errors

#HTTPError Source

type HTTPError = BasicError ()

Basic error type containing the common http errors.

#AjaxError Source

type AjaxError = BasicError ParseError

Extends HTTPError to add json parsing errors.

#_unAuthorized Source

_unAuthorized :: SProxy "unAuthorized"

#_serverError Source

_serverError :: SProxy "serverError"

#_parseError Source

_parseError :: SProxy "parseError"

#_notFound Source

_notFound :: SProxy "notFound"

#_methodNotAllowed Source

_methodNotAllowed :: SProxy "methodNotAllowed"

#_formatError Source

_formatError :: SProxy "formatError"

#_forbidden Source

_forbidden :: SProxy "forbidden"

#_badRequest Source

_badRequest :: SProxy "badRequest"