Fork me on GitHub
#clojurescript
<
2021-08-27
>
valerauko08:08:22

or you could use a library that can handle it for you

valerauko08:08:26

like httpurr

winsome20:08:05

I went with axios for http, that works across node and browser envs. But now I need to do the same thing for websockets and I can't find anything that covers both environments, so I'll just have to figure it out at runtime

winsome20:08:41

however, I'm running into a problem while trying to check if js/window exists - I get an error:

Execution error (ReferenceError) at (<cljs repl>:1).
window is not defined

winsome20:08:41

But when I try wrapping it in a try catch, like this:

(try js/window
       :js
       (catch js/ReferenceError e
         :node))
it returns :js

winsome20:08:52

So I think I'm misunderstanding how this evaluates

Derek20:08:30

Can you use cljs.core/exists?

winsome20:08:36

perfect, that does exactly what I need.