How do you fellow helixers fetch on the browser ? Do you use js/fetch or its wrapper https://github.com/lambdaisland/fetch or something else.
I think I've found an issue in https://github.com/lambdaisland/fetch/issues/19
promesa looks well written/behaved wrapper. No dependencies, documentation.
Yeah, I trust most of the funcool libs, they are battle tested in https://github.com/penpot/penpot
@brandon746 Didn't knew about this project. Thank you for pointing it.
https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L106 this p/try block from kitchen-async has no equivalent on promesa, so i changed the p/let inside the p/try to . That proves @dominicm point, native .then and .catch are more than enough for operations. I'm using p/promise constructor on decode-body in case the implementation (its a multi-method) does not give a promise back.
the fetch operation https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L105 is not being guarded by the p/try block, which opens the door to something wrong with it. the p/let block captures a response, the fetch api says it does not reject on 404 errors. it only rejects on network errors. the next promise operation is https://github.com/lambdaisland/fetch/blob/main/src/lambdaisland/fetch.cljs#L113 decode-body. I wonder how the https://github.com/athos/kitchen-async/blob/master/src/kitchen_async/promise.cljc#L126 p/try from kitchen-async is able to intercept rejected promises on the code. I know the code is there but my brain is not lispy enough to understand how. Is it really feasible ? because the native promise handling is dependent on chainning, and I think promises are different from exceptions semantically.
despite the kitchen-async dependency pulling core.async, I liked lambdaisland.fetch. It pairs with muuntanja at server side, which responds to content-type. It defaults to asking for transit content, and has multi-methods to decode body based on the content-type.
I use js/fetch
@dominicm Do you use a library for promises ?
No I remember: lambdaisland pulls kitchen-async which pulls core-async which is on hold for https://www.juxt.pro/radar 2021
I don't. I'm passing the JSON as a JavaScript object around