content icon indicating copy to clipboard operation
content copied to clipboard

Using fetch: Mixing await/async and .then/.finally syntax

Open theking2 opened this issue 3 years ago • 1 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

What specific section or headline is this issue about?

No response

What information was incorrect, unhelpful, or incomplete?

The page starts of with a basic Promis .then/.finally syntax and then without warning shows the async/await method of fetch. I suggest Remove the .then basic sample as it confuses the following examples and replace it with async/await basic sample.

Also the examples are getting quit specific for a page that give an overview.

I could also image a basic fetch() page that explains the two syntaxes and juxtaposition to XMLHttpRequest and than on another detailed page show simple, multiple files, CORS and other examples.

What did you expect to see?

A succinct illustration of fetch

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

https://www.smashingmagazine.com/2020/11/comparison-async-await-versus-then-catch/

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/fetch_api/using_fetch
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/fetch_api/using_fetch/index.md
  • Last commit: https://github.com/mdn/content/commit/0444ab41bb372e63b3345f50e5b1e4e6a96c21d5
  • Document last modified: 2023-02-24T12:04:34.000Z

theking2 avatar Mar 01 '23 11:03 theking2

Looks like the main part of this (conversion to async/await) got done in https://github.com/mdn/content/pull/25819.

wbamberg avatar Sep 13 '23 06:09 wbamberg

As noted in https://github.com/mdn/content/issues/24982#issuecomment-1717008789, the main part of this is done. For the rest:

Also the examples are getting quit specific for a page that give an overview.

I could also image a basic fetch() page that explains the two syntaxes and juxtaposition to XMLHttpRequest and than on another detailed page show simple, multiple files, CORS and other examples.

https://github.com/mdn/content/pull/34278 is a rewrite of the fetch guide. I haven't opted to split it at this point although I do think there's an argument for doing so. I think it would be best to make https://github.com/mdn/content/pull/34278 the fix for this issue (among others), and address this issue by making and discussing feedback on that PR.

wbamberg avatar Jun 20 '24 16:06 wbamberg