This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-04
Channels
- # announcements (27)
- # babashka (1)
- # beginners (70)
- # calva (3)
- # cljfx (4)
- # clojure (37)
- # clojure-australia (1)
- # clojure-europe (1)
- # clojure-germany (6)
- # clojurescript (5)
- # conjure (4)
- # cursive (2)
- # data-science (3)
- # datomic (20)
- # events (1)
- # fulcro (9)
- # graalvm (7)
- # jobs-discuss (3)
- # joker (1)
- # malli (2)
- # pathom (2)
- # re-frame (8)
- # reitit (1)
- # shadow-cljs (44)
- # sql (16)
- # xtdb (8)
hi there! I have a beginner's question regarding the use of cljs-ajax via :http-xhrio. How to send POST data? Scrabbled some docs but I still fail with this code:
(rf/reg-event-fx ::save-draft
(fn [coeffects event]
(let [db (:db coeffects)
location (get event 1)
draft (a/get-draft-text db location)]
{:db (assoc db :show-twirly true)
:http-xhrio {:method :post
:uri "/api/save-file"
:params {:location location :draft draft}
:timeout 8000 ; optional see API docs
:response-format (ajax/json-response-format {:keywords? true})
:on-success [::draft-saved]
:on-failure [::draft-not-saved]}})))
Maybe you see some grave errors from the code? Error message in browser console is Uncaught Error: ["unrecognized request format: " nil]
I have these lines in my code:
;; With nil body, `cljs-ajax` cannot guess for us.
:format (when (nil? (:body params)) (ajax/url-request-format))
@U2FRKM4TW Hey! Thanks. I'll have a look into it... Merci!
Hey @U2FRKM4TW you rock! This did the trick:
:body {:location location :draft draft}
instead of
:params {:location location :draft draft}
Now I run into server trouble (400) but this a a different topic. 1000 Thanks!