Fork me on GitHub
#re-frame
<
2020-10-16
>
motform14:10:39

I have a very stupid problem with re-frame-http-fx, for some reason it does not seem to honor my :format key and instead always sends the request with *Content-Type:* application/x-www-form-urlencoded;charset=UTF-8, which means that muuntaja fails to decode the request body. When I send the same payload over curl manually setting the headers, it works and decodes. Am I doing something wrong or have I misunderstood? If I read the the clj-ajax docs it claims that the default content-type should be edn, but removing the :format key does nothing. (reg-event-fx ::submit-session (fn [_ [_ session]] {:http-xhrio {:method :post :uri "" :timeout 8000 :body (util/->transit+json session) :format (ajax/transit-request-format) :response-format (ajax/transit-response-format {:keywords? true}) :on-failure [:http/failure]}}))

p-himik04:10:35

Use :params instead of :body. Note that :params expects something that has not been encoded yet.

❤️ 3
motform13:10:23

oh crap, of course, I thought :params where for query params only. thank you!

👍 3
kaosko22:10:27

I have a complex ui element (like on the level of a small application), distributed as its own library. let's say the purpose of it is to describe properties of a house. in one application I want to use this complex ui element and show multiple data for multiple houses. Is it the best way to pass along the id for the house in every function call (rf dispatch/subscribe) or is there some other, more clever pattern for this? I'd almost like to initiate the view with the id of the house (if this was o-o). Perhaps the best plan is to store the id in a url and get it from the for each sub/dispatch call? unless I'm missing something even simpler

p-himik04:10:11

With quite a bit of discussion and other links at https://github.com/day8/re-frame/issues/264

kaosko08:10:05

Thanks @U2FRKM4TW, I'm glad that the documentation certainly has gotten better - it's been a while since I last visited the page. It's interesting to note I had arrived at the exact same best practice concepts without reviewing the documentation. first, that I have to pass the id along and that I can at least package the args into entity specific fns. Perhaps I was looking for yet another level but this at least confirms I'm on the right path