lambdaisland/fetch

Content-type and accept headers are always transit+json

Closed this issue · 3 comments

I'm trying out this invocation, where I set the :content-type and :accept options as :json:

(fetch/request
   "https://pokeapi.co/api/v2/pokemon/35/"
   :content-type :json
   :accept :json)

And seeing application/transit+json in the request headers via the browser's network panel:

:authority: pokeapi.co
:method: GET
:path: /api/v2/pokemon/35/
:scheme: https
accept: application/transit+json
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
content-type: application/transit+json

This happens no matter what I set the :accept and :content-type options AFAICT. Am I misunderstanding something?

Options have to be a map, not keyword options.

oh wow, the signature totally confused me - I see now the options map is inside the destructure of the varargs. Why is that?

Closing for now since this appears to be PEBKAC

It's to make the second argument optional. We could have used a multi-arg function here with separate one and two-arg versions, which arguably would be better. More readable and potentially better compiled output, not sure about that last one. If you're in the mood for it a small PR for that would certainly be welcome.