Fork me on GitHub
Elias Elfarri17:07:10

If i send some paramtrrs into a rest API with a GET request using reg-event-fx with reframe, and i wqnt the backend to access the data through a compojure set up, is it enough to do the following? `(defroutes app (GET “/“ [a b] (response (+ a b)))` Assuming that a and b are data that are sent into the restAPI and that everything todo with ring middleware and json wrapping is taken care of? I guess this is more of a compojure question but idk where to post it.


Take like 10 steps back. Your get handler there needs to handle the request in some way. When you say (GET "/" [a b] ...) where does it take the info from in the request to get a and b


can it do that?


once you can call your api with curl, then you can shift to figuring out how to construct a request from the frontend

Elias Elfarri17:07:27

I guess i wasnt being precise enough, i am wondering more about how to access the json data with compojure. If i know it has a format {”a”: 1}, how do you access that data with destructuring?

Elias Elfarri18:07:34

Is it as easy as using a vector?


sorry, twas busy


if you have json decoded into a map


if its like this


{:a 1 :b 2}


you can destructure it like this


(let [{:keys [a b]} json] ...)


if its like this


{"a" 1 "b" 2}


you can destructure it like this


(let [{:strs [a b]} json] ...)

AJ Jaro01:07:38

@U027C7611DF with compojure you'll usually be working with the request object on the route. So it's not that much different from what @U3JH98J4R mentioned but just slightly where you'd have to get some values out of the body of the request structure in order to see the map you passed into the API

Elias Elfarri17:07:58

Also i assume that frontend uses the same route