Skip to content

Web API Request json() method does not list the Exceptions #41689

@valerii15298

Description

@valerii15298

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Request/json

What specific section or headline is this issue about?

Exceptions

What information was incorrect, unhelpful, or incomplete?

The Exceptions section is absent

What did you expect to see?

Something like:

Exceptions

  • TypeError
    • : Thrown for one of the following reasons:
      • The response body is disturbed or locked.
      • There was an error decoding the body content (for example, because the {{httpheader("Content-Encoding")}} header is incorrect).
  • SyntaxError
    • : The response body cannot be parsed as JSON.

Do you have any supporting links, references, or citations?

.json method is shared method on Body mixin by the spec:
https://fetch.spec.whatwg.org/#body-mixin
https://fetch.spec.whatwg.org/#dom-body-json

Do you have anything more you want to share?

I thought that the Exceptions could be the same as for Response .json instance method: https://developer.mozilla.org/en-US/docs/Web/API/Response/json#exceptions

But it seems like AbortError should not be there, because even if you abort signal, exceptions are not thrown in any runtimes(chrome, safari, deno, bun, node) I tested with this code:

const controller = new AbortController();
const request = new Request("https://google.com", {
  method: "POST",
  body: "{}",
  signal: controller.signal,
});

controller.abort();
request.json().then(() => console.log("Success"));

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions