May I ask what is a simple way for me to view the contents of my :db
?
re-frame-10x or re-frisk
How do I access the value actually? Or must it be through a subscription?
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
.
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
Just follow the guide in the README.
Whoops yeah was confused for a moment, but found the explanation on that after including re-frame-10x on its own!
Also, debux
readme mentions:
> still a work in progress and there'll likely be little annoyances and bugs, perhaps even big ones
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 "<https://stuartstein777.github.io/fitness/daily.json>"
: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?Both of your formats use json-request-format
function. One of them should be a response format, IIRC.
aaaaaaaaaaaaargh! you are correct, i never noticed that
thank you.
I've been looking at that code for 30 mins now, trying to see whats wrong. You spot it immediately sigh
Well, the error does hint at it with its "Format should have been". :)