Created
June 24, 2016 10:20
-
-
Save alwx/6a5050bf17140307f4b8f9d9700a5d84 to your computer and use it in GitHub Desktop.
This file contains 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
(def transit-reader (t/reader :json)) | |
(-> (js/fetch api-url | |
(clj->js {:headers {"Accept" "application/transit+json"}})) | |
(.then (fn [response] | |
(.text response))) | |
(.then (fn [response] | |
(let [data (t/read transit-reader response)] | |
;; we're done | |
;; `data` is a clojurescript map | |
;; and we're able to use this map any way we want | |
(dispatch [:api-method-call-success data])))) | |
(.catch (fn [error] | |
(dispatch [:api-method-call-error error])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment