Description
if the responseHandler
equals to json
(the default), rtk doesn't set the Accept
header to application/json
, effectively allowing the server to send any response format, since the default for Accept
is */*
. however, this is in contradiction to that we expect json to be returned from the server, since this is what our configured handler will parse. I was quite surprised by that so maybe I'm missing something. let me know!
most server will probably happily respond with json, even though Accept
is not set properly. but this is just due to that most apis only support json, so they always return json and pay no attention to the header. but apis also returning other formats, lets say xml and html, might return xml, if that is their default, instead of json, if the Accept
header is not constraining the expected format.
it could be also argued that Accept
should be text/plain
if the responseHandler
is text
, but that might be too far, since "plain text" is not well defined (or we expect html or similar as a response, which is handled as 'text'
as well), compared to json.