在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:dariooddenino/purescript-simple-ajax开源软件地址:https://github.com/dariooddenino/purescript-simple-ajax开源编程语言:PureScript 90.9%开源软件介绍:Purescript-Simple-AjaxAn opinionated library to work with AJAX and JSON, using Thanks to Vladimir Ciobanu for his error handling solution. FunctionsAll requests have 4 versions:
Requests payload objects must implement an instance of Check argonaut-codecs documentation to learn more about this. Requests
type SimpleRequest = { headers :: Array RequestHeader
, username :: Maybe String
, password :: Maybe String
, withCredentials :: Boolean
} For example: getR { withCredentials: true } "http://www.google.it" Headers and MediaTypeThe default requests sets the header ErrorsThe different types of error ( There are two type alias:
By using let error =
default "Generic error"
# on _notFound $ const "Not found"
# on _badRequest identity
# on _parseError $ intercalate ", " <<< map renderForeignError
$ err Example usageimport Prelude
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Data.Variant (default, on)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Class.Console (log, logShow)
import Simple.Ajax (_unAuthorized, post)
payload :: { foo :: Int, bar :: String }
payload = { foo: 1, bar: "hello" }
type Baz = { baz :: Boolean }
main = launchAff_ $ do
res <- post url (Just payload)
case res of
Left err -> do
let error =
default "Generic error"
# on _unAuthorized (const "Not authorized")
$ err
log error
Right (res :: Baz) ->
logShow res NOTE: To run this in the console you will need to install
Module documentationModule documentation is published on Pursuit. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论