Fork me on GitHub
#re-frame
<
2022-03-18
>
popeye22:03:34

I have defined below event in the my application referring from https://github.com/day8/re-frame-http-fx , But this does not calling ::success-post-result handler, I am using lein figwheel dev for server running , also I have imported [day8.re-frame.http-fx] in the file, Am i missing aything?

(re-frame/reg-event-fx
  ::http-post
  (fn [_world [_ val]]
    {:http-xhrio {:method          :post
                  :uri             ""
                  :params          data
                  :timeout         5000
                  :format          (ajax/json-request-format)
                  :response-format (ajax/json-response-format {:keywords? true})
                  :on-success      [::success-post-result]
                  :on-failure      [::failure-post-result]}}))

p-himik22:03:46

Are you sure the response is successful? Are you sure there's a response at all?

p-himik22:03:02

You can use your browser's DevTools to check the network requests.

p-himik22:03:19

Also, confirm that there are no exceptions in the JS console.

popeye22:03:07

ok, I am referring to this now

(reg-event-fx                             ;; note the trailing -fx
  :handler-with-http                      ;; usage:  (dispatch [:handler-with-http])
  (fn [{:keys [db]} _]                    ;; the first param will be "world"
    {:db   (assoc db :show-twirly true)   ;; causes the twirly-waiting-dialog to show??
     :http-xhrio {:method          :get
                  :uri             ""
                  :timeout         8000                                           ;; optional see API docs
                  :response-format (ajax/json-response-format {:keywords? true})  ;; IMPORTANT!: You must provide this.
                  :on-success      [:good-http-result]
                  :on-failure      [:bad-http-result]}}))

popeye22:03:39

and oncalling :on-request there is no call to that event. Also my db is becoming nil

popeye22:03:56

atleast it should call that handler right? Also I added printn statement before this I am getting that log

popeye23:03:40

[buttons/button-text-widget :button-connect-ls [:div [:button.btn-ini.btn-connect "Connect [:button-wrapper] #(disp :connect)]

popeye23:03:41

@U2FRKM4TW I am calling as above

p-himik23:03:03

> my db is becoming nil That's a likely symptom of using one of the event handlers incorrectly. Your button code doesn't have anything useful in there, and it's definitely broken. Maybe you copy-pasted it wrongly.