superstructor / re-frame-fetch-fx

js/fetch Effect Handler for re-frame
MIT License
40 stars 8 forks source link

Add Response body reader func support #4

Closed marc-sabates-gelpi closed 3 years ago

marc-sabates-gelpi commented 3 years ago

Hi Isaac, Thanks for the library, it's good stuff!

I have created this PR with some changes I've made to support custom response content types. In a nutshell the PR adds :response-content-types support for maps with 2 keys.

Here is an example of usage:

{:fetch {:url "/example.edn"
         :method :get
         :response-content-types {#"application/.*json" :json
                                  #"application/edn" {:reader-kw :text
                                                      :reader-fn read-string}}
          ,,,
}}

This PR is only intended for you to see and consider if this particular way of supporting customs responses types may be interesting.. There are many ways to skin a cat..

Cheers..

superstructor commented 3 years ago

Thanks @marc-sabates-gelpi 👍 😄 Nice work.