Fork me on GitHub

Hi, I'm have a question about using promesa async/await in clojurescript(in node). I have this function:

(defn get-json [url]
  (let [result 
            (dotimes [i 3]
              (p/await (p/delay 100))
              (println "i=" i))
            [{:a "hello"}])]
And I required
[promesa.core :as p]
            [promesa.async-cljs :refer-macros [async]]
However, when I call get-json I'm getting an error:
(montaigne.fns/get-json "aa")
Execution error (Error) at (<cljs repl>:1).
No protocol method IDeref.-deref defined for type object: [object Promise]
Any hints? It should be possible to have synchronous looking code in ClojureScript running in node, right?


@podviaznikov cljs promesa doesn't support deref aka @ - once you are in async-land, there is no escape!


(instead of derefing, compose further then actions onto your promises)


yeah, makes sense. Thanks 🙏 I wish there was escape:)


Ok, There might be sync http request in node. I'm writing CLI, so for me sync requests are fine, no need for async io