Fork me on GitHub
#re-frame
<
2020-10-24
>
Rafał Wyszomirski17:10:53

Hello. Can you recommend some http client that works nicely with re-frame/cljs?

p-himik17:10:50

https://github.com/day8/re-frame-http-fx for re-frame. It wraps cljs-ajax which you can use directly if you're not using re-frame.

Rafał Wyszomirski17:10:15

Yes, that's what I am using currently. Unfortunately it returns response body only and I haven't found a good way to extract the whole response with status code and headers and such. Unless you know how to do it right in re-frame ;) I'm still learning so sorry if the question is obvious.

Rafał Wyszomirski17:10:43

Other than that, I think http-fx is pretty cool

p-himik18:10:32

Seems like specifying (ajax.ring/ring-response-format) as the response format might get you the headers and the status code. I haven't tried it though.

Rafał Wyszomirski18:10:53

Okay, thank you very much. I will try it out 👍

Rafał Wyszomirski18:10:25

@U2FRKM4TW Thanks for setting me up on the right track. I ended up using:

:response-format (ajax/ring-response-format {:format (ajax/json-response-format)})
Though I must say the documentation for it which says "`ring-response-format` takes one parameter: format" is not the same as "takes one paramater, which is a map that accepts one key only, i.e. :format that has to be one of response-formats listed earlier"... Anyway, thanks a lot 🙏

👍 3
p-himik18:10:16

Source code is always the answer. :) More often with time I tend to consult it before the documentation.

👍 3
Rafał Wyszomirski18:10:15

Yeah... I'm still getting accustomed to clj code but I was so frustrated that such an obvious thing took me 2 days...

👍 3