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

问题描述 投票:0回答:1

[像这样发出cljs-http.client请求后:(http/get ...),并尝试prn响应,我得到以下信息:

cljs.core.async.impl.channels.ManyToManyChannel

如何await(如JS)此对象以获取实际响应?

-编辑-

正在做

   (prn "result is " (go (let [result (<! (http/get "http://myurl.com"))]
                               result
                )))

仍然给我“结果是cljs.core.async.impl.channels.ManyToManyChannel”

而我正在期待一个对象。

asynchronous clojurescript
1个回答
0
投票

/ cljs-http /中的所有HTTP函数均返回core.async渠道。请求完成或失败后,将其放在该请求上渠道。您可以使用<!从该通道获取响应函数内部 go块。

  (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)))))

来源:https://github.com/r0man/cljs-http#async-response-handling

© www.soinside.com 2019 - 2024. All rights reserved.