Fork me on GitHub
#clojurescript
<
2022-05-27
>
Sameer Thajudin06:05:41

What is a good Clojurescript library to call Rest APIs?

Aaron Burdick06:05:29

I've no professional experience with clojurescript, but this looks promising https://github.com/JulianBirch/cljs-ajax

πŸ‘ 3
augustl08:05:28

I just call js/fetch directly

πŸ‘ 4
augustl08:05:37

for example:

(async/go
  (let [res (<p! (js/fetch
                    "/foo"
                    (clj->js {:opts "here"})))]
    (when (= 200 (.. res -status))
      (let [body (-> (.. res (json))
                     (<p!)
                     (js->clj))]
        ...)))

πŸ™Œ 3
πŸ‘ 3
pinkfrog14:05:12

I go with axios and adds a simple wrapper. Anyway, I have to add some simple wrapper to the libs regardless if it is cljs or js.

πŸ‘ 3
grav13:06:45

Big fan of https://funcool.github.io/httpurr/latest/ as it supports both nodejs, browser and java.

armed13:05:30

Hello, everyone. Is there any way to dynamically mark functions with export metadata using macro during compilation?

armed13:05:00

I have a configuration file with symbols that should be exported, I plan to read that file with macro and prevent name mangling.

sansarip15:05:31

I think this should do what you’re asking πŸ‘‡

(defmacro export [& var-names]
  (let [var-names (set var-names)]
    (doseq [[k v] (ns-publics *ns*)]
      (when (contains? var-names k)
        (alter-meta! v assoc :export true)))))
Adapted from https://twitter.com/borkdude/status/1526555062365040641?s=20

armed15:05:16

Thanks, I tried alter-meta! approach, It works perfect on clojure side, but on cljs side function meta is unchanged. Not sure what happening.

armed06:05:43

Ok, now everything works. Thanks again @U022T96EFV3

sansarip13:05:04

Np! What was the secret sauce?

armed06:05:50

No secrets at all, just fixed idiotic typos πŸ˜ƒ

πŸ”₯ 1