You need to update a user's email and then delete their old address record using Angular's HttpClient. Which sequence correctly performs these operations?
hard📝 component behavior Q8 of 15
Angular - HTTP Client
You need to update a user's email and then delete their old address record using Angular's HttpClient. Which sequence correctly performs these operations?
ACall <code>post('/api/users', updatedEmail)</code> then <code>delete('/api/addresses/oldId')</code>
BCall <code>delete('/api/addresses/oldId')</code> first, then <code>put('/api/users/1', updatedEmail)</code>
CCall <code>put('/api/users/1', updatedEmail)</code> first, then <code>delete('/api/addresses/oldId')</code>
DCall <code>put('/api/addresses/oldId', updatedEmail)</code> then <code>delete('/api/users/1')</code>
Step-by-Step Solution
Solution:
Step 1: Update user email
Use PUT on the user resource URL with updated email data.
Step 2: Delete old address
Use DELETE on the old address resource URL.
Step 3: Sequence matters
Update first to ensure data consistency, then delete obsolete data.
Final Answer:
Call put('/api/users/1', updatedEmail) first, then delete('/api/addresses/oldId') -> Option C
Quick Check:
Update then delete in sequence [OK]
Quick Trick:Update resource with PUT, then delete obsolete with DELETE [OK]
Common Mistakes:
MISTAKES
Deleting before updating causing data loss
Using POST instead of PUT for update
Mixing resource URLs
Master "HTTP Client" in Angular
9 interactive learning modes - each teaches the same concept differently