cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
macrobartfast 2021-05-13T01:05:34.498600Z

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]
            [<http://clojure.java.io|clojure.java.io> :as io]))
and my handler is
(defroutes handler
  (GET "/about" [] "&lt;h1&gt;Hello World&lt;/h1&gt;")
  ;; (POST "/test" req (prn (read (:body req))))
  (POST "/test" req (:body req))
  (route/not-found "&lt;h1&gt;Page not found&lt;/h1&gt;"))
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.

macrobartfast 2021-05-13T01:06:23.499200Z

I’m open to total changes in approach… whatever I have here is just from my thrashing along.

dpsutton 2021-05-13T01:07:06.499500Z

did you mean to put this in #cider?

macrobartfast 2021-05-13T01:07:17.499800Z

the front end is using cljs-http.

macrobartfast 2021-05-13T01:07:20Z

omg.

dpsutton 2021-05-13T01:07:24.000300Z

ha 🙂

macrobartfast 2021-05-13T01:07:26.000400Z

so absolutely sorry.

dpsutton 2021-05-13T01:07:29.000700Z

no worries at all

macrobartfast 2021-05-13T01:07:39.001100Z

what a catastrophe, sorry cider people.

🙂 1
dpsutton 2021-05-13T01:07:55.001300Z

not a problem 🙂