Fork me on GitHub
Brandon Olivier03:06:42

I'm trying to return json from a request in luminus, but I keep getting an error like java.lang.IllegalStateException: Can't coerce body of type class clojure.lang.PersistentArrayMap

Brandon Olivier03:06:00

but the body type is a string, not a persistent array map (I don't think)

Brandon Olivier03:06:22

I added these routes to the main route handler that comes configured

(defn about [request]
  (->  "{\"foo\": \"bar\"}"
      (response/header "Content-Type" "application/json")))

(defn api-routes []
   {:middleware []}
   ["/about" {:get about}]])

Brandon Olivier04:06:16

When I hit the endpoint, I get a 500 response, and the Content-Type is octet-stream instead of json


the coercions should be handled by the middleware automatically, so you should just be able to return (response/ok {:foo :bar})


apologies for the basic question - in Luminus (or clojurescript) is there anything built-in for creating a list of files in a folder in the resources directory? Or should I reach for a npm library? thanks!