A. Assigning json directly to data instead of data.value
B. Missing await keyword before fetch
C. Using onMounted instead of created lifecycle hook
D. Not returning the fetch promise
Solution
Step 1: Check how ref is updated
Refs in Vue must be updated by setting their .value property, not the ref variable itself.
Step 2: Identify incorrect assignment
The code assigns json directly to data, which breaks reactivity; it should be data.value = json.
Final Answer:
Assigning json directly to data instead of data.value -> Option A
Quick Check:
Update ref with .value [OK]
Hint: Update ref variables with .value, not direct assignment [OK]
Common Mistakes:
Forgetting .value when setting ref
Confusing async/await with then chaining
Thinking onMounted is wrong lifecycle hook here
5. You want to fetch user data and show a loading message while waiting. Which Vue 3 <script setup> code correctly implements fetch with loading and error states?