在像这样发出 cljs-http.client 请求后:(http/get ...)
,并尝试 prn
响应,我得到以下信息:
cljs.core.async.impl.channels.ManyToManyChannel
如何等待
(如在 JS 中)此对象以获得实际响应?
-- 编辑--
做
(prn "result is " (go (let [result (<! (http/get "http://myurl.com"))]
result
)))
仍然给我“结果是 cljs.core.async.impl.channels.ManyToManyChannel”
而我期待的是一个对象。
最佳答案
All HTTP functions in /cljs-http/ return a core.async channel. When a request has completed or failed it is put on that channel. You can take the response from that channel with the
<!
function within ago
block.(go (let [response (<! (http/get "https://api.github.com/users" {:with-credentials? false :query-params {"since" 135}}))] (prn (:status response)) (prn (map :login (:body response)))))
Source: https://github.com/r0man/cljs-http#async-response-handling
关于asynchronous - 如何在 clojurescript 中等待 cljs.core.async.impl.channels.ManyToManyChannel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60365869/