I am working with base om tutorial by David Nolan. But I am with a problem when I try send a POST to my back-end. Basically I use the same code from om tutorial. I test back-end separately e it works as expects:
curl -X POST -d "foo=bar" http://localhost:10555/posts
Params: {:foo "bar"}%
Bu when I trying from ClojureScript the params is empty. I do:
Code from Om tutorial:
(def ^:private meths
{:get "GET"
:put "PUT"
:post "POST"
:delete "DELETE"})
(defn edn-xhr [{:keys [method url data on-complete]}]
(let [xhr (XhrIo.)]
(events/listen xhr goog.net.EventType.COMPLETE
(fn [e]
(on-complete (reader/read-string (.getResponseText xhr)))))
(. xhr
(send url (meths method) (when data (pr-str data))
#js {"Content-Type" "application/edn"}))))
The request:
(edn-xhr
{:method :post
:url (str "posts")
:data {:name "Foo Bar"}
:on-complete
(fn [res]
(println "server response:" res))})
)
;;=> server response:
I don't figured out whats is the problem here. If I missed some important information in this post, please, let me know.
Thanks in advance.
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/ddwLLRIygiE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.