Vue · Middle · Question 24 of 75

What happens when <script setup> contains a top-level await?

<script setup>
const user = await fetch("/api/me").then((r) => r.json());
</script>

Explanation

<Suspense> waits for async descendants and shows its #fallback slot meanwhile. It is still marked experimental, so many teams prefer explicit loading state.

Further reading

Problem with a question

Vue · Middle · question 24

Test yourself

Take the Vue · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz