Closed
Bug 1296704
Opened 9 years ago
Closed 5 years ago
Add text example to Fetch API's Response object article
Categories
(Developer Documentation Graveyard :: API: DOM, defect, P5)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: machineghost, Unassigned)
References
()
Details
:: Developer Documentation Request
Request Type: New Documentation
Gecko Version: unspecified
Technical Contact:
:: Details
Your MDN documentation is normally stellar, and I always pick it over those idiots at W3 Schools. However, when I was reading the documentation for the Response object (returned from a "fetch"), I realized that someone made a poor choice when creating the example.
I say this because the example demonstrates how to fetch a binary object (in this case a jpeg) using fetch. However, 99.9% of AJAX requests on the web aren't for images, or any other binary file: they're for text (usually, but not always JSON). Because the example demonstrates the binary data case, it completely fails to explain the far more common text case. As a result I was forced to leave MDN to go figure out how Response works somewhere else.
A very simple "here's how you fetch some JSON text" example would probably be very easy to write, and (I think) would be far more useful to most developers.
Updated•9 years ago
|
Component: JavaScript → API: DOM
Reporter | ||
Comment 1•9 years ago
|
||
P.S. Having learned the basic pattern:
fetch('/foo')
.then((response) => response.json())
.then((json) => doSomething(json))
it certainly seems so basic and simple that there's no need for an example. But if you don't have the proper frame of reference and all you have is the API definition of the json method of Response (which returns a promise, not the json of the response, contrary to what one might naively expect), then it can be hard to get to the above pattern ... which is why I think even a simple example could be valuable to new learners.
Comment 2•9 years ago
|
||
Probably this page
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
Comment 3•9 years ago
|
||
Personally, I feel we should have both a binary example and a text example here, rather than replacing the binary example we currently have.
Reporter | ||
Comment 4•9 years ago
|
||
@sheppy I wholeheartedly agree. I just meant that the non-binary case was, of the two, more useful to more people.
But if multiple examples are possible then I think one for each case would be great, as the two cases are unique enough that they would each illustrate something different and wouldn't be redundant.
Updated•9 years ago
|
Summary: Example for "Response" Is Poorly Chosen → Add text example to Fetch API's Response object article
Comment 5•5 years ago
|
||
MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•