hey guys how do i use js/fetch in scittle π my post request doesn't work doing it like that (js/fetch some-url {:method "POST" :body (js/JSON.stringify {:bla "bla"})})
Sorry I meant js/fetch function
What about the js/fetch function?
I used to run the function like this (js/fetch some-url {:method "POST" :body (prn {:bla "bla"})}) assuming that prn convert the map to json.stringify based on the readme in github. However, the body on the server is nil. I just tried what @mathaeus.peter.sander did initially and worked.
pr-str works as well
Prn is a side effecting function which prints
And that function returns nil
Itβs best to manually call JSOn stringify in squint rather than using pr-str
Use #js {:body ...} since js/fetch is a JavaScript thing, not a CLJS library
or use clj->js
aaaaaah i see
i guess i should more ofter refer to squint π
when using scittle
hrm now the issue is that my send data is edn π
(js/fetch api-url #js {:method "POST" :body {:dataType "json" :q (:search-term @state)}})
btw can scittle use the js-await ?you need to also write :body #js {....} , #js isn't recursive
or use clj->js which is recursive
scittle doesn't support js-await, but it comes with promesa which helps dealing with promises
Does the same applies for squint?
please specify "the same"
in squint you don't have to write #js because that is the only thing that exists, everything is JS data structures
also, squint supports js-await