Fork me on GitHub
#re-frame
<
2020-04-22
>
franklineapiyo14:04:25

I'm trying to make requests to a server as stated in the documentation (using a :htttp-xhrio effect).

franklineapiyo14:04:31

Something like this

(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]}}))

franklineapiyo14:04:46

and I'm wondering how to pass in credentials to that request

franklineapiyo14:04:59

How can I pass in a password and username?

franklineapiyo14:04:38

Any help will be appreciated, if anything isn't clear, I can clarify

franklineapiyo14:04:07

I've tried to look for this information in the documentation for cljs-ajax as well as `re-frame-http-fx` and couldn't find it

p-himik14:04:35

What type of auth to you want to use?

franklineapiyo14:04:01

But I'd also like to know how other kinds of auth can be done...

p-himik14:04:22

Have you tried setting the :headers field?

p-himik14:04:28

> other kinds of auth If it's just a web app, I wouldn't try anything else but cookies with a session ID.

franklineapiyo14:04:38

how do I add a username and password to the headers?

p-himik15:04:21

It's literally in the first sentence on the Wiki page about HTTP Basic auth. :)

franklineapiyo15:04:44

let me check...

franklineapiyo15:04:32

Yeah it is the first sentense 😆

aisamu15:04:07

Hi! What's the canonical way of deriving data when one subscription is parametrised by the value of another subscription? Here's a contrived example:

(rf/reg-sub
 ::derived
 :<- [::value]
 (fn [value]
   {:foo @(rf/subscribe [::b-given-a value])}))
IIRC we can use reg-sub-raw to subscribe+`deref` at will, but I'm unsure if the above is also fine

pshar1016:04:49

How do I use reframe in the repl?

pshar1016:04:14

In my project it works, but in the connected shadow-cljs repl, the dispatches and the subscribes are returning nil