day8 / re-frame-http-fx

A re-frame "effects handler" for performing Ajax tasks (via cljs-ajax)
MIT License
259 stars 27 forks source link

Does not work without :format provided for method :get #43

Closed IvannikovG closed 10 months ago

IvannikovG commented 4 years ago

I am using an example provided in README.

(rf/reg-event-db :good-http-result (fn [db [_ result]] (println db) (assoc db :api-result result)))

(rf/reg-event-db :bad-http-result (fn [db [_ result]] (assoc db :api-result result)))

(rf/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 "https://api.github.com/orgs/day8" :timeout 8000 :response-format (ajax/json-response-format {:keywords? true}) :on-success [:good-http-result] :on-failure [:bad-http-result]}}))

In browser I get "Error: unrecognised format"

If I specify format: ":format :json" (this and other endpoints I tried return json), then I get nil when I print db in :good-http-result

IvannikovG commented 4 years ago

To fix one should bump down dependency of ajax-core to the same this library uses