Dynamic reference to the underlying Javascript sync-request
module.
Note: sync-request
is not bundled with cljs-sync-request
. See set-sync-request!
Dynamic reference to the underlying Javascript [`sync-request`](https://github.com/ForbesLindesay/sync-request) module. Note: `sync-request` is not bundled with `cljs-sync-request`. See `set-sync-request!`
(clj->json e)
A no assumption clj->JSON encoding function used by all json-*
request methods with a :body
. Can be replaced by
specifying :encode
in the opts
of any request method.
A no assumption clj->JSON encoding function used by all `json-*` request methods with a `:body`. Can be replaced by specifying `:encode` in the `opts` of any request method.
method
used to perform a DELETE
request
`method` used to perform a `DELETE` request
method
used to perform a GET
request
`method` used to perform a `GET` request
method
used to perform a HEAD
request
`method` used to perform a `HEAD` request
(json->clj s)
A no assumption JSON->clj decoding function used by all json-*
request methods decode a response :body
. Can be
replaced by specifying the :decode
in the opts
of any request method.
A no assumption JSON->clj decoding function used by all `json-*` request methods decode a response `:body`. Can be replaced by specifying the `:decode` in the `opts` of any request method.
(json-delete url)
(json-delete url {:as opts})
Performs a synchronous JSON DELETE request to the specified url
Performs a synchronous JSON DELETE request to the specified `url`
(json-get url)
(json-get url {:as opts})
Performs a synchronous JSON GET request to the specified url
Performs a synchronous JSON GET request to the specified `url`
(json-head url)
(json-head url {:as opts})
Performs a synchronous JSON HEAD request to the specified url
Performs a synchronous JSON HEAD request to the specified `url`
(json-post url body)
(json-post url body {:as opts})
Performs a synchronous JSON POST request to the specified url
with a given edn body
transformed into JSON
Performs a synchronous JSON POST request to the specified `url` with a given edn `body` transformed into JSON
(json-put url body)
(json-put url body {:as opts})
Performs a synchronous JSON PUT request to the specified url
with a given edn body
transformed into JSON
Performs a synchronous JSON PUT request to the specified `url` with a given edn `body` transformed into JSON
method
used to perform a POST
request
`method` used to perform a `POST` request
method
used to perform a PUT
request
`method` used to perform a `PUT` request
(request method
url
{:keys [body] :as context}
{:keys [encode decode inflate deflate]
:or
{encode identity decode identity inflate identity deflate identity}
:as opts})
Performs a sync-request
with an encode
d body and inflate
d context. The {:keys [status body headers] :as response}
is then returned deflate
d and with a decode
d body. Refer to sync-request#Options
for all available features of
the context map including :timeout, :retry, :maxRetries, :qs, and more.
opts map
:encode - A function that takes the body from the context and transforms it before performing the request. Defaults to clj->json
for JSON requests
:decode - A function that takes the body of the response and decodes it before returning a result. Defaults to json->clj
for JSON requests
:inflate - A function that takes the full context and transforms it before performing the request.
:deflate - A function that takes the full response and transforms it before returning a result.
(request POST {:body {:id "123"} :headers {"Accept" "application/json"}} {:encode (fn [request-body] (assoc request-body :token "456")) :decode (fn [response-body] (-> response-body json->clj (assoc :response-time (js/Date.)))) :inflate (fn [request] (assoc-in request [:headers "Authorization"] (str "Bearer 890"))) :deflate (fn [response] (dissoc response :headers))})
Performs a `sync-request` with an `encode`d body and `inflate`d context. The `{:keys [status body headers] :as response}` is then returned `deflate`d and with a `decode`d body. Refer to `sync-request#Options` for all available features of the context map including :timeout, :retry, :maxRetries, :qs, and more. opts map :encode - A function that takes the body from the context and transforms it before performing the request. Defaults to `clj->json` for JSON requests :decode - A function that takes the body of the response and decodes it before returning a result. Defaults to `json->clj` for JSON requests :inflate - A function that takes the full context and transforms it before performing the request. :deflate - A function that takes the full response and transforms it before returning a result. (request POST {:body {:id "123"} :headers {"Accept" "application/json"}} {:encode (fn [request-body] (assoc request-body :token "456")) :decode (fn [response-body] (-> response-body json->clj (assoc :response-time (js/Date.)))) :inflate (fn [request] (assoc-in request [:headers "Authorization"] (str "Bearer 890"))) :deflate (fn [response] (dissoc response :headers))})
(set-sync-request! sync-request)
Sets sync-request to the Javascript sync-request
function
Sets *sync-request* to the Javascript `sync-request` function
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close