This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-14
Channels
- # adventofcode (4)
- # announcements (11)
- # babashka (1)
- # beginners (45)
- # calva (31)
- # cider (12)
- # clj-kondo (1)
- # cljdoc (9)
- # cljs-dev (5)
- # cljsrn (11)
- # clojure (42)
- # clojure-australia (1)
- # clojure-germany (14)
- # clojure-italy (1)
- # clojurescript (20)
- # conjure (2)
- # cursive (11)
- # datomic (5)
- # emacs (2)
- # events (1)
- # fulcro (24)
- # graalvm (1)
- # honeysql (69)
- # malli (2)
- # off-topic (13)
- # reagent (12)
- # reitit (1)
- # shadow-cljs (14)
- # specter (2)
- # tools-deps (21)
- # uncomplicate (4)
Hi everyone. I’m building a website using reagent + re-frame, and using reitit for routing. I’m having a little trouble understanding how to match query parameters passed through a URL into a path. I have a couple of routes setup as such:
(def routes
["/"
[""
{:name :routes/home
:view views/home
:controllers
[{:start (fn [& params] (js/console.log "Entering home page"))
:stop (fn [& params] (js/console.log "Leaving home page"))}]}]
["?search=:term"
{:name :routes/search
:view views/results-panel
:parameters {:query {:search {:term string?}}}
:link-text "Search"
:controllers
[{:parameters {:query {:search :term}}
:start (fn [] (re-frame/dispatch [::events/get-results :term]))}]}])
When I try passing a string matching the :routes/search
path, it matches against the :routes/home
path instead
(r/match-by-path routes "/?search=hello")
=> #reitit.core.Match{:template "/", :data {...}, :result nil, :path-params {}, :path "/", :query-params {:search "hello"}, :parameters {:path {}, :query {:search "hello"}}}
I feel like there’s something pretty simple here that I’m missing, though I’m not quite sure