I am sending a map via a POST using cljs-http and I want to receive it with a Compojure POST handler and store it in a database. I'm totally confused as what I am supposed to do with the map in transit... there are a lot of options... pr-str, prn, read-string and on and on. On the sending side, it seems cljs-http might coerce my map into edn on it's own. I have no way of knowing without a working Compojure handler.
Actually, to be honest, I'm still a bit unclear on what edn is. It's Clojure's data format, that I gather. As far as I can tell, what I am dealing with is actually just converting edn into a string format for shipping and back out. However, the :data value on the request is an object, not a string. A working example of a cljs-http POST and a Compojure POST handler that allows me to work with the original map sent by the client would be awesome. I don't know the purpose of :edn-params in my
(http/post "/test" (:edn-params (prn-str {:hey "there"})))
or if I should be using something else. I am used to JSON and am wondering if I should just be converting the data to JSON and back out on the receiving side. I'm unsure of the advantages of using edn.
On the receiving side I have:
(defroutes handler
(GET "/about" [] "<h1>Hello World</h1>")
(POST "/test" req (prn (read (:body req))))
(route/not-found "<h1>Page not found</h1>"))
I know this likely wrong... but I thought I'd share where I am at.
UPDATE: After some thought, the title should have been 'What is the best way to send maps between a Reagent app and a server?". I just need to be able to send a map to a server, and make requests to that server and get a map back.