我使用cljs-ajax成功地从一个端点获得了响应(如下所示)。但是,我似乎无法在我的响应处理程序中区分不同的成功状态代码。
(ns mynamespace
(:require [ajax.core :as ajax]))
(defn start-monitoring []
(let [handler (fn [[ok response]]
(if ok
(.log js/console response)
(.error js/console (str response))))]
(ajax/ajax-request {:uri "/myendpoint"
:method :get
:params {:since (.getTime (js/Date.))}
:handler handler
:format (ajax/json-request-format)
:response-format (ajax/json-response-format {:keywords? true})})))响应主体是响应中返回的任何文本,并且看起来不包含状态代码,除非请求失败。
如何确定响应的状态代码?
发布于 2017-04-13 02:04:56
似乎响应是一个带有键的映射,比如:status,它包含200个用于我的测试的键。其余的键是:(:status :failure :response :status-text :original-text)
发布于 2019-06-24 11:15:17
使用:response-format (ajax/ring-response-format)。另请参阅:https://github.com/JulianBirch/cljs-ajax/issues/57
https://stackoverflow.com/questions/43364460
复制相似问题