JulianBirch / cljs-ajax

simple asynchronous Ajax client for ClojureScript and Clojure
670 stars 136 forks source link

detect-response-format does not respect :type of :response-format #278

Open jtkDvlp opened 1 year ago

jtkDvlp commented 1 year ago

detect-response-format does not respect :type of sub :response-format. As you can see here https://github.com/JulianBirch/cljs-ajax/blob/359e83ca0cd628c22252ba861860cb921622a618/src/ajax/xhrio.cljs#L22 the response type is set at creation not resolving the type of response-format. This can cause pr/-body to return the wrong data type.

Further more the content-type of detect-response-format (*/*) is used in addition to the content types of response-format. I thought it would only use the types of response-format?

bgalartza commented 1 year ago

Also interested on this. Did you find any workaround or fix?

My understanding of the code is that setResponseType is called before the request is triggered. And detect-response-format relies on the response. So maybe this is not possible?