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}

Explanation

If the promise changes, the block switches back to the pending state. {:catch} and the pending part are optional.

Further reading

Problem with a question

Svelte · Junior · question 20

Test yourself

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

Take this quiz