Open
Description
When interacting with a server that can respond with either JSON or an HTML document, is there a way to gracefully handle the response with minimal code? Specifically, I want to attempt parsing the response as JSON and, if that fails, fall back to treating it as plain text. Additionally, I would like the response.clone()
to be handled automatically in the background.
Expected Behavior
- Attempt to parse the response as JSON.
- Fallback to plain text if JSON parsing fails.
- Automatically handle
response.clone()
to avoid issues with consuming the body multiple times.
Metadata
Metadata
Assignees
Labels
No labels