Hi David

I'm new to core.async (and clojurescript) so i'm not sure if it's my usage or 
not but the get-json! "/api/login" works in Chrome - however with FF I get an 
exception in getJsonResponse when it tries to parse an empty object -  I don't 
see any network activity which makes me think it's core.async, otherwise how on 
earth would i get to the response unless the rewriting has gone wrong somewhere?

(defn get-json
  ([url cb]
     (get-json url cb nil "GET"))
  ([url cb data]
     (get-json url cb data "POST"))
  ([url cb data method]
     (gxhrio/send url
                  (fn[e] 
                    (let [xhr (.-target e)]
                      (cb (js->clj (.getResponseJson xhr)))))
                  method
                  (when data
                    (qd/createFromMap (clj->js data))))))

(defn get-json!
  ([url]
   (let [c (chan)]
       (get-json url (fn [resp] (put! c resp)))
       c))
  ([url data]
     (let [c (chan)]
       (get-json url (fn [resp] (put! c resp)) data)
       c)))


called like this ...

(defn try-login []
  (let [pkt (form-fields "frm-login")]
    (println "login pkt " pkt)
    (go 
      (let [data (<! (get-json! "/api/login" pkt))]
         (if (=  (data "status") "ok")
             (on-login (data "sess"))
             (on-login-failure))))))

Is my usage sound?

Thanks

R

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to