我有以下ClojureScript代码来发出POST请求:
(defn perform-post [resource]
"Performs a post and returns the body :)"
(go (let [response (<! (http/post resource))]
(:body response))))
当我调用返回数字的资源时
(js/console.log (perform-post post-create-recipe-url))
打印:
buf
对象{buf = {...},n = 1,cljs $ lang $ protocol_mask $ partition0 $ = 2,
更多...}
buf
对象{head = 1,tail = 0,length = 1,meer ... } arr
[“ 6276677237104933520”,未定义]
我想获取“ 6276677237104933520”(邮件正文)信息作为“返回”值。
我该怎么做?我试过了,<!!
但由于未定义,所以它不起作用。
阻塞语义(<!!
)在ClojureScript平台上不可用。
您只能在go
块内从通道检索值:
(go (js/console.log (<! (perform-post post-create-recipe-url))))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句