Today I had a hard time to find out how I can parse custom return messages from compojure with cljs-ajax error handler for POST/GET request. So this is the code that works:

[codesyntax lang=“bash“]

;server side

(defn method []
	(something that fails)
    (catch Exception e
      {:status 500 :body {:message "Error message."}}

;cljs side
(defn error-handler [{:keys [response]}]
  (js/alert (:message response)))

(defn test-connection []
  (POST "/url"
        {:params        (get-form-data)
         :handler       succ-handler
         :error-handler error-handler
         :response-format :json
         :keywords? true}))


So there are two key points here, first:

:response-format :json

:keywords? true

You need these two keys set to be able to parse a response.

The param list has to look like this:

[{:keys [response]}]

To get the response map from the server.

I only figured this out thanks to a nice guy from: