This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-01
Channels
- # announcements (5)
- # beginners (151)
- # calva (4)
- # cider (32)
- # cljdoc (27)
- # cljsrn (2)
- # clojars (15)
- # clojure (66)
- # clojure-houston (2)
- # clojure-india (1)
- # clojure-italy (3)
- # clojure-uk (7)
- # clojurescript (15)
- # data-science (1)
- # datomic (2)
- # fulcro (6)
- # off-topic (24)
- # pedestal (1)
- # re-frame (20)
- # reagent (3)
- # remote-jobs (4)
- # rewrite-clj (2)
- # shadow-cljs (9)
- # spacemacs (5)
- # tools-deps (4)
- # vim (1)
- # yada (4)
is there an easy way to get the response headers when using [day8.re-frame/http-fx "0.1.6"]
. I'm getting a list of paginated github issues and would like to get the links headers entry which gives me pagination next and last links
I'm new to all this, but maybe using the :response-headers option ? It's mentioned in the readme for cljs-ajax.
in https://github.com/JulianBirch/cljs-ajax/blob/master/README.md there's 4 usages of the word "header" and all refer to the request headers. I'm not seeing which part you're talking about
yeah that's the request headers. but not (easy) way to inspect the headers on the way back
(:require
[ajax.core :as ajax]
[ajax.json :as ajax.json]
[ajax.protocols :refer [-body -get-response-header -get-all-headers]]
[ajax.interceptors :refer [map->ResponseFormat]])
(def json-and-header-response
(map->ResponseFormat
{:read (fn json-read-response-format [xhrio]
{:body (ajax.json/read-json-native nil true (-body xhrio))
:headers (-get-all-headers xhrio)})
:description "JSON with headers"
:content-type ["application/json"]}))
with this i do. I'm sending {:body .. headers ...}
The built in version only calls your onsuccess with the parsed body
There should be a way to do that from the re-frame layer. He says this in xhrio doc. The supplied value should be an options map as defined by the simple interface ajax-request see: api docs. Except for :on-success and :on-failure. All options supported by ajax-request should be supported by this library, as it is a thin wrapper over ajax-request
. Of course it goes to the other readme, which Im sure you've read a million times.
that's true. this is the response reader. The standard ones just return the body. The one above is very similar to the json one (mostly cut and paste) but also includes the headers
What happens if you add those options to your re-frame version ? In the code it looks like they should pass through.
In the code it only looks for the response from the xhrlo object. The link is dead. But here are the docs for xhrlo. There is a method to get the headers, I think the handler just ignores them. https://developers.google.com/closure/library/docs/xhrio
I don't have a working http-fx
ATM, but you could look into https://github.com/JulianBirch/cljs-ajax/blob/5c9a79dafee0a08860a28a1d818581c921517db3/src/ajax/protocols.cljc#L37.
Maybe you need to check the type
of response.
Oh, I see the discussion https://github.com/Day8/re-frame-http-fx/issues/7
And the work being done https://github.com/superstructor/re-frame-http-fx/commit/458e6264011275d40d613cbf15830f2714f090dc
I was thinking that the response will be record, but it turns out I was not attentive enough.
So @U11BV7MTK you need http-fx 0.2.0.