gpt4 book ai didi

asynchronous - 如何在 clojurescript 中等待 cljs.core.async.impl.channels.ManyToManyChannel?

转载 作者:行者123 更新时间:2023-12-05 03:55:11 26 4
gpt4 key购买 nike

在像这样发出 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 a go 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com