Skip to content

Update_index.md - #45716

Closed
raghuveer5465 wants to merge 2 commits into
mdn:mainfrom
raghuveer5465:patch-1
Closed

raghuveer5465 wants to merge 2 commits into
mdn:mainfrom
raghuveer5465:patch-1

Conversation

@raghuveer5465

@raghuveer5465 raghuveer5465 commented Sep 15, 2026 •

Copy link
Copy Markdown

Description

Fixed a code example that used await outside of an async function, which would cause a syntax error in a plain script context. Wrapped the fetch calls in an async function main() and invoked it.

Motivation

The original example used await fetch(request) directly at the top level, which only works in module scripts or environments that support top-level await. Since this snippet is a plain inline script example, it would throw a SyntaxError: await is only valid in async functions. Wrapping the logic in an async function makes the example runnable as-is for readers copying the code into a regular script.

Additional details

No new APIs or behavior introduced — this is purely a fix to make the existing Request/fetch example (demonstrating that a request body can only be consumed once) executable in a standard script context.

@raghuveer5465
raghuveer5465 requested a review from a team as a code owner September 15, 2026 09:00
@raghuveer5465
raghuveer5465 requested review from sideshowbarker and removed request for a team September 15, 2026 09:00
@github-actions github-actions Bot added Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed labels Sep 15, 2026
@saitanallensantiago26-beep

This comment was marked as spam.

@Josh-Cena

Copy link
Copy Markdown
Member

Top-level await is not forbidden on MDN. In fact the examples immediately above and below it both use TLA. You just need to put it into a module.

@Josh-Cena Josh-Cena closed this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/xs [PR only] 0-5 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants