Vaniall macchiato app, created as per documentation
lein new macchiato first
The request looks like this:
curl -H "Content-Type: application/json" \ -H "Accept: application/json" \ -X POST -d '{"foo":"bar"}' http://localhost:3000/bar
The bar function looks like this
(defn bar [req res raise]
(println req)
(-> "bar"
(r/ok)
(r/content-type "application/json")
(res)))
route looks like
“/bar” {:post bar}
the middleware looks like
(defaults/wrap-defaults handler defaults/api-defaults)
What do I need to do in order to be able to parse the body of the request?
Doing something like this:
(js/JSON.parse (:body req))
complains about
SyntaxError: Unexpected token o in JSON at position 1
Thanks