Skip to content

Instantly share code, notes, and snippets.

@souenzzo
Created November 22, 2022 13:29
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 souenzzo/10f42bfc90d3272ab8f304b168cf5c0d to your computer and use it in GitHub Desktop.
Save souenzzo/10f42bfc90d3272ab8f304b168cf5c0d to your computer and use it in GitHub Desktop.
(-> (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