Closed fregante closed 3 weeks ago
I don't know if it would bring substantial code improvements over the above code, but it would avoid having to figure out the various Content-Type strings
How common is it to not know upfront what type you will be receiving? What is the use-case for such a thing?
Not very.
This specific scenario could be because it's a user-provided API endpoint. In reality APIs can also return "the wrong type", as seen in https://github.com/sindresorhus/ky/issues/375
So for example .auto()
could handle both a proper JSON response and raw text, both of which would eventually be a valid "JsonValue"
I'm manually doing content detection:
Would it make sense to have an
.auto()
parser that deals with the content type automatically? JSON, FormData, Blob, etc. I think that's what Axios does for example (but it returnsunknown
as a type)