Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@danielneal
Forked from qleguennec/events.cljs
Last active September 7, 2017 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielneal/7957d6b7f78a7ccaa4ad3f1dcf1df64f to your computer and use it in GitHub Desktop.
Save danielneal/7957d6b7f78a7ccaa4ad3f1dcf1df64f to your computer and use it in GitHub Desktop.
(rf/reg-event-fx
:auth
(fn [{:keys [db]} _]
{:POST
{:url "https://api.intra.42.fr/oauth/token"
:on-success [:auth/response-received]
:on-fail :auth-nok
:params
{:grant_type "client_credentials"
:client_id "secret"
:client_secret "secret"}}}))
;; Separate event handler has access to the db and the response
(rf/reg-event-db
:auth/response-received
(fn [db [_ resp]]
(assoc db :token (get resp :access_token)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment