cljs-http icon indicating copy to clipboard operation
cljs-http copied to clipboard

Uncaught ReferenceError: cljs_http is not defined

Open xlisp opened this issue 4 years ago • 2 comments

I use the cljs-http in chrome extension, it's version "0.1.46" . but i get this error:


(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)))))
截屏2021-02-04 上午12 09 44

xlisp avatar Feb 03 '21 16:02 xlisp

Hi there. Could you solve that problem, I get the same error in similar circumstances.

(ns myproject.rap.api
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [cljs-http.client :as http]
            [cljs.core.async :refer [<!]]))

(defn get-document [lemmisee]
  (go (let [response (<! (http/get "https://api.github.com/users" 
                                   {:with-credentials? false
                                    :query-params {"since" 135}}))]
        (prn response))))

Opening the repl and calling (get-document 1) leaves me with following message:

myproject.rap.api=> (get-document 1)
#object[TypeError TypeError: Cannot read properties of undefined (reading 'get_document')]
         (<NO_SOURCE_FILE>)

Calling only the http/get request, says me, that cljs_http is not defined:

(<! (http/get "https://api.github.com/users"
                                 {:with-credentials? false
                                  :query-params {"since" 135}}))

#object[ReferenceError ReferenceError: cljs_http is not defined]
         (<NO_SOURCE_FILE>)

I already removed all from ./target/dev and also refreshed cache in ~/.m2/repository. But it leaves me with this error.

Any hints?

ulrichschinz avatar Nov 29 '22 15:11 ulrichschinz

Hi there,

I solved the problem. I just didn't require the new created file, which in turn required the other stuff (like cljs-http). After requiring it in another file, it just worked fine. Given the example above I had to do a

(:require [myproject.rap.api :as api])

Then I could just use it.

ulrichschinz avatar Dec 04 '22 12:12 ulrichschinz