-
-
Save danielneal/7957d6b7f78a7ccaa4ad3f1dcf1df64f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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