Open njerig opened 3 years ago
You need to define a ResponseFormat
that reads & returns what you want instead of just the formatted body returned by the defaults (json-response-format, text-response-format etc) :
(defn my-json-response-format [{:keys [prefix keywords? raw]}]
(int/map->ResponseFormat
{:read (fn [xhrio]
{:body (ajax.json/read-json-native raw keywords? (ajax.protocols/-body xhrio))
:status (ajax.protocols/-status xhrio)
:status-text (ajax.protocols/-status-text xhrio)
:response-headers (ajax.protocols/-get-all-headers xhrio)
:was-aborted (ajax.protocols/-was-aborted xhrio)})
:description (str "JSON"
(if prefix (str " prefix '" prefix "'"))
(if keywords? " keywordize"))
:content-type ["application/json"]}))
How do I get the response headers from a raw response? I've tried looking at the
headers
object in the response XhrIo object, but itsmap_
andkeys_
are empty.