Fork me on GitHub
#shadow-cljs
<
2021-11-28
>
Hagenek13:11:30

I am having some issues with shadowCljs and importing a compenent where I use ajax.core to fetch some data. When fire-ing up the REPL with Calva I get the following import error. Anyone encountered this?

========= Running Tests =======================
SHADOW import error /Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/todana.components.gigpage.api.js

/Users/hagenek/repos/reframe-reagent/todana/.shadow-cljs/builds/test/dev/out/cljs-runtime/goog/net/xmlhttp.js:173
    return new XMLHttpRequest();
    ^
ReferenceError: XMLHttpRequest is not defined

wontheone106:11:17

I had a similar problem. How do we fix it?

Burin22:12:36

Here is how I solve this problem:

npm install xhr2

Burin22:12:20

Then try

(:require ["xhr2" :as xhr2]
..)

(set! js/XMLHttpRequest xhr2)

👍 1
thheller13:11:17

looks like you are in a node repl but using code meant for the browser

polymeris20:11:56

In the docs, section https://shadow-cljs.github.io/docs/UsersGuide.html#_project_clj_leiningen, it says "For example :lein {:profiles "+cljs"}". Should that be :profile?