Created
November 22, 2022 13:29
-
-
Save souenzzo/10f42bfc90d3272ab8f304b168cf5c0d 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
(-> (js/fetch "/api.json") | |
(.then (fn [response] | |
;; I can access the response/headers, but can't access the json/body. :( | |
(.json response))) | |
(.then (fn [json] | |
;; I can access the json/body, but can't access the response/headers. :( | |
...))) | |
(-> (js/fetch "/api.json") | |
(.then (fn [response] | |
(.then (.json response) | |
(fn [json] {:res response :json-body json})))) | |
(.then (fn [{:keys [res json-body]}] | |
;; Access both response/headers and json/body :) | |
...))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment