C. Calling getReader() directly on response instead of response.body.
D. Not decoding value before logging.
Solution
Step 1: Check how getReader() is called
getReader() must be called on response.body, not on response itself.
Step 2: Identify the error cause
Calling response.getReader() will cause a runtime error because response has no such method.
Final Answer:
Calling getReader() directly on response instead of response.body. -> Option C
Quick Check:
Use response.body.getReader() [OK]
Hint: getReader() is on response.body, not response [OK]
Common Mistakes:
Calling getReader() on response
Forgetting to decode chunks
Thinking while(true) always causes infinite loop
5. You want to display a loading message that updates with each chunk of streamed data in Svelte. Which approach correctly updates the UI as chunks arrive?
hard
A. Update a local variable inside the async function without reactive binding.
B. Wait for all chunks, then update the UI once with the full data.
C. Use setTimeout to delay UI updates until streaming finishes.
D. Use a writable store to append each decoded chunk and bind it to the UI.
Solution
Step 1: Understand UI reactivity in Svelte
Svelte updates the UI when reactive variables or stores change.
Step 2: Choose a method to update UI per chunk
Using a writable store to append each chunk triggers UI updates as data arrives.
Step 3: Why other options fail
Waiting for all chunks delays UI update; setTimeout delays unnecessarily; local variable changes without binding won't update UI.
Final Answer:
Use a writable store to append each decoded chunk and bind it to the UI. -> Option D
Quick Check:
Writable store + binding = live UI updates [OK]
Hint: Use writable store to update UI reactively per chunk [OK]
Common Mistakes:
Updating local variables without reactive binding
Waiting for full data before UI update
Using timers instead of reactive stores
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.