Skip to content

Accept header missing if responseHandler === 'json' #3870

Open
@pseidemann

Description

@pseidemann

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions