Reputation: 4201
The route setup detailed below causes the error: Wrong number of args (0) passed to: PersistentArrayMap
Can anyone help me understand this error and how to resolve it?
(defn sign-in [req]
({:status 200 :body "hello world" :headers {"content-type" "text/plain"}}))
(defroutes paths
(GET "/connect" {} connect-socket)
(POST "/sign-in" {} sign-in)
(route/resources "/")
(route/not-found "Resource not found."))
(def app
(-> (defaults/wrap-defaults #'paths defaults/api-defaults)
wrap-json-params))
Upvotes: 1
Views: 550
Reputation: 1261
fix your sign-in function by unwrapping the response map
(defn sign-in [req]
{:status 200 :body "hello world" :headers {"content-type" "text/plain"}})
the problem is, you put a map in a function position (first element of a list) and it requires a argument.
(
{:status 200 :body "hello world" :headers {"content-type" "text/plain"}} ;; function
??? ;; argument
)
in clojure, map can act as a function with key as its argument and returns value of that key, ex
({:a 1 :b 2 :c 3} :a)
=> 1
Upvotes: 7