Liking cljdoc? Tell your friends :D

cljs-sync-request

A ClojureScript wrapper around the NPM sync-request module

Note: cljs-sync-request does not bundle with sync-request

Latest Version

Clojars Project cljdoc badge CircleCI

Why?

Sometimes you just need to perform a synchronous HTTP requests without worrying about entering callback hell or propagating core.async go blocks and channels throughout your code. I use cljs-sync-request primarily in AWS Lambda functions where I don't need to do any asynchronous work and am typically wait for a result before continuing processing.

As the base sync-request library suggests, you are unlikely to want to use this library in production.

Example Usage

(ns io.axrs.cljs-sync-request.example
  (:require
    [io.axrs.cljs.sync-request.core :refer [json-post set-sync-request!]]
    ["sync-request" :as sync-request]])) ; When using shadow-cljs

(set-sync-request! sync-request)

(defn check-status []
  (let [{:keys [status body headers] :as response} (json-post "https://some.url/here" {:id "1234"})]
    (if (= 200 status)
      (continue-processing body)
      (handle-other-codes response))))

Can you improve this documentation? These fine people already did:
Alexander Scott & Alexander R Scott
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close