Svelte · Middle · Question 55 of 75
What is the purpose of +page.server.js returning a promise for slow data?
export async function load() {
return {
post: await getPost(),
comments: getComments(), // not awaited
};
}- ✓Correct answer: The page renders with
postimmediately andcommentsstreams in later; use{#await data.comments}in the page - 2It's a bug: all data must be awaited
- 3It makes the request run in the browser
Explanation
Streaming improves time to first content. On platforms without streaming support, the response waits for everything.