XMLHttpRequest binding for purescript.
please read Module documentation if you want to know about other hooks.
getQuery = get defaultAjaxOptions
{ onReadyStateChange = onSuccess $ \response -> do
txt <- getResponseText response
Debug.Trace.trace txt
} "/api/foo" {queryParam: "bar"}
postQuery1 = post defaultAjaxOptions
{ onReadyStateChange = onSuccess $ \response -> do
txt <- getResponseText response
Debug.Trace.trace txt
} "/api/bar" {} (urlEncoded {param: "bar"})
postQuery2 = post defaultAjaxOptions
{ onReadyStateChange = onSuccess $ \response -> do
txt <- getResponseText response
Debug.Trace.trace txt
} "/api/bar" {} (multipart {param: "bar"})
abortQuery = do
task <- get defaultAjaxOptions "/api/foo" {}
abort task
syncQuery = do
task <- get defaultAjaxOptions { async = false } "/api/baz" {}
txt <- getResponseText (unsafeToResponsege task)
Debug.Trace.trace txt
delete = ajax defaultAjaxOptions
{ method = "DELETE"
, url = "/api/qux"
} {} noBody