Fork me on GitHub
#clojurescript
<
2022-10-22
>
hifumi12304:10:14

What HTTP library do people often use in cljs frontends? I'm having trouble choosing between cljs-ajax, cljs-http, and fetch. I remember using Got for some HTTP stuff in TypeScript, but really what I am after is a lispy wrapper over XHR or fetch with as little extra dependencies as possible. The most specific requirements I have is the ability to send GET, PATCH, POST, and DELETE and get a response map back.

athomasoriginal15:10:07

Fetch. Keeps it simple and dependencies low.

hifumi12317:10:52

Awesome. I'll choose fetch then. Thanks!

wevrem19:10:06

I’m using cljs-ajax, mostly because I’m also using re-frame and re-frame-http-fx (which depends on cljs-ajax). I’m happy with it because I’m in control of both FE and BE so I can round trip with transit and provide my own custom request and response formatters. Not saying that can’t be done with other HTTP libraries, but this setup has worked well so far for me.

souenzzo15:10:46

js/fetch or http://goog.net.XhrIo, for partial/progress results.

alex22:10:23

Hi there, I'm looking to do a bit of introspection via cljs.test . Is there a way to get the test name inside of an each fixture?

alex16:10:17

Related: is it possible to get the test name from within a deftest body, or would I need to write a macro that wraps deftest to achieve that?

Alex Miller (Clojure team)16:10:56

In Clojure,

(-> test/*testing-vars* last symbol str)
will give you the name of the test you're in at runtime, not sure if same works in CLJS

Alex Miller (Clojure team)16:10:12

looks like from the cljs docs, there is an equivalent :testing-vars property in the test environment

Alex Miller (Clojure team)16:10:22

(:testing-vars (get-current-env)) presumably will give you the equivalent

alex18:10:09

Thank you, that works perfectly!

alex18:10:55

For the first question, borkdude pointed me to https://clojure.atlassian.net/browse/CLJ-840, which seems to suggest that accessing the test name within the fixture function is not yet supported, either in JVM Clojure or Cljs

alex16:10:17

Related: is it possible to get the test name from within a deftest body, or would I need to write a macro that wraps deftest to achieve that?