Closed
Description
Hello! I'm having a problem with duplicated query params, I need to receive a list of parameters on the server, I'm using compojure, so if I go with:
;; server
(defroutes routes
(GET "/" {{:strs [list-of-vals]} :query-params :as request}
(println list-of-vals)))
;; ["1" "2"]
;; client
GET /?list-of-vals=1&list-of-vals=2
This works great with an XMLHttpRequest (or other clients), but not with cljs-http.
So, if I try to parse multiple params with the same name:
(println (http/parse-query-params "/?list-of-vals=1&list-of-vals=2&list-of-vals=3"))
{:/api?list-of-vals 1, :list-of-vals 3}
(println (http/parse-query-params "/?list-of-vals=1&list-of-vals=2&list-of-values=2"))
{:/api?list-of-vals 1, :list-of-vals 2, :list-of-values 3}
Given that query params are handled with a map this behaviour is expected
(-> {}
(assoc :list-of-vals 1)
(assoc :list-of-vals 2))
;; {:list-of-vals 2}
Given all that, how do you handle a list of query params correctly? This looks like a common [1,2] practice.
1- http://stackoverflow.com/a/2602127/600052
2- http://stackoverflow.com/a/13261403/600052
Metadata
Metadata
Assignees
Labels
No labels