`Obsidian.requestUrl` attempts to parse the response body as JSON even if content-type is not set

When I make a request using Obsidian.requestUrl, it attempts to parse the response body as JSON even if the content-type is not set. This means it’s not possible to handle responses with an HTTP status code only because requestUrl throws an error internally, and all the response data is not available at the call site. In my opinion, JSON parsing should happen only if the response is application/json.

If you’re only wanting the status can you use fetch()?

Or request - Developer Documentation will perform a request without parsing to JSON.

Correct me if I’m wrong, but raw fetch doesn’t have requestUrl CORS goodies?

Well it depends on what exactly you’re trying to fetch. But request() does have CORS and doesn’t attempt to parse as JSON.

But request returns just body as a plain string without any response properties.