This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-13
Channels
- # announcements (8)
- # architecture (11)
- # babashka (159)
- # beginners (112)
- # biff (4)
- # chlorine-clover (4)
- # cider (10)
- # clj-kondo (51)
- # cljs-dev (43)
- # cljsrn (10)
- # clojure (45)
- # clojure-bay-area (5)
- # clojure-europe (11)
- # clojure-france (4)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-norway (1)
- # clojure-sweden (1)
- # clojure-uk (8)
- # clojurescript (75)
- # code-reviews (1)
- # community-development (2)
- # conjure (88)
- # cryogen (5)
- # data-science (1)
- # datomic (3)
- # dirac (2)
- # fulcro (4)
- # helix (1)
- # jackdaw (5)
- # kaocha (5)
- # leiningen (2)
- # lsp (49)
- # malli (9)
- # mid-cities-meetup (1)
- # off-topic (8)
- # pathom (3)
- # polylith (19)
- # re-frame (6)
- # releases (3)
- # rewrite-clj (1)
- # shadow-cljs (98)
- # spacemacs (2)
- # tools-deps (6)
- # vim (4)
- # xtdb (6)
I’ve created a project with create-cljs-app, which is awesome. However, now I’ve enabled the server option in shadow-cljs.edn, which allows me to add routes, and I want to send data from the front-end to the back. To send a map, I would have to turn it into a string or JSON, right? Two questions (I think): what format is best to send and receive it in? And, assuming I’m right in that I have to wrap the Ring or Compojure routes, how and where do I do this in an app created with create-cljs-app? I don’t have a familiar instance to wrap, as create-cljs-app is a little different than what I set up myself. In my shadow-cljs-edn I have:
:dev-http {8080 {:root "public"
:handler app.handler/handler}}
and my handler ns requires are:
(ns app.handler
(:require [crux.api :as crux]
[compojure.core :refer :all]
[compojure.route :as route]
[muuntaja.middleware :as mw]
;; [ring.middleware.json :as json]
[ :as io]))
and my handler is
(defroutes handler
(GET "/about" [] "<h1>Hello World</h1>")
;; (POST "/test" req (prn (read (:body req))))
(POST "/test" req (:body req))
(route/not-found "<h1>Page not found</h1>"))
which returns the request at /test. I need to be able to send a map from the front end and send it off to Crux.I’m open to total changes in approach… whatever I have here is just from my thrashing along.
the front end is using cljs-http.
so absolutely sorry.