Fork me on GitHub
#re-frame
<
2021-06-12
>
zackteo09:06:01

May I ask what is a simple way for me to view the contents of my :db ?

p-himik09:06:20

re-frame-10x or re-frisk

zackteo09:06:31

How do I access the value actually? Or must it be through a subscription?

p-himik09:06:25

With those tools - they do it for you. On your own - a public API would be to use a sub or an event handler. A private API would be @re-frame.db/app-db.

zackteo09:06:18

Okay! Btw do you happen to know if I need to include [re-frame/tracing] for re-frame 10x? Seems like it has been replaced by re-frame-debux

p-himik09:06:19

Just follow the guide in the README.

zackteo09:06:34

Whoops yeah was confused for a moment, but found the explanation on that after including re-frame-10x on its own!

p-himik09:06:53

Also, debux readme mentions: > still a work in progress and there'll likely be little annoyances and bugs, perhaps even big ones

Stuart21:06:11

I'm going through the re-frame docs for getting data from servers using day8.re-frame.http-fx. I have my reg-event-fx like below:

(rf/reg-event-fx
 :get-stuff
 (fn [{:keys [db]} _]
   {:http-xhrio {:method          :get
                 :uri             ""
                 :format          (ajax/json-request-format)
                 :response-format (ajax/json-request-format {:keywords? true})
                 :on-success      [:process]
                 :on-failure      [:fail]}
    :db db}))
My success handler:
(rf/reg-event-db
 :process
 (fn [db [_ data]]
   (js/console.log "here: " data)
   (assoc db :bar (:status-text data))))
My fail handler:
(rf/reg-event-db
 :fail
 (fn [db [_ bad]]
   (js/console.log "fail :(" bad)
   (assoc db :bar (:status-text bad))))
It ALWAYS goes into fail handler with the error:
Cannot read property 'cljs$core$IFn$_invoke$arity$1' of null Format should have been
I have no idea what that error is meant to be telling me: Here's what it looks like in the browser console: It's fetching the json OK. Anyone any idea what the error means?

p-himik21:06:59

Both of your formats use json-request-format function. One of them should be a response format, IIRC.

Stuart21:06:53

aaaaaaaaaaaaargh! you are correct, i never noticed that

Stuart21:06:56

thank you.

Stuart21:06:19

I've been looking at that code for 30 mins now, trying to see whats wrong. You spot it immediately sigh

p-himik21:06:26

Well, the error does hint at it with its "Format should have been". :)