-
Notifications
You must be signed in to change notification settings - Fork 22.9k
Open
Labels
Content:WebAPIWeb API docsWeb API docsaccepting PRFeel free to open a PR to resolve this issueFeel free to open a PR to resolve this issuearea: Fetch/XMLHttpRequest
Description
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).
- : Thrown for one of the following reasons:
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
Labels
Content:WebAPIWeb API docsWeb API docsaccepting PRFeel free to open a PR to resolve this issueFeel free to open a PR to resolve this issuearea: Fetch/XMLHttpRequest