Svelte · Junior · Question 20 of 76
What does the {#await} block do?
{#await promise}
<p>Loading…</p>
{:then user}
<p>{user.name}</p>
{:catch error}
<p>{error.message}</p>
{/await}- ✓Correct answer: Renders different content for the pending, fulfilled and rejected states of a promise
- 2Pauses the whole component until the promise resolves
- 3Runs the promise on the server only
Explanation
If the promise changes, the block switches back to the pending state. {:catch} and the pending part are optional.