Assuming the API requires an item ID to delete a specific item.
medium
A. DELETE requests cannot be sent without a request body
B. The URL is missing the item ID to specify which item to delete
C. The subscribe method is missing a parameter
D. The console.log statement is incorrect
Solution
Step 1: Check the URL for DELETE request
The URL 'api/items' does not specify which item to delete; an ID is needed.
Step 2: Understand API requirements
APIs usually require an ID in the URL like 'api/items/1' to delete a specific item.
Final Answer:
The URL is missing the item ID to specify which item to delete -> Option B
Quick Check:
DELETE URL needs item ID = C [OK]
Hint: DELETE URL must include resource ID to delete [OK]
Common Mistakes:
Sending DELETE without specifying resource ID
Thinking DELETE needs a request body
Ignoring subscribe callback
5. You want to update a user's profile and then delete their old profile picture in Angular. Which sequence of HttpClient calls correctly applies PUT and DELETE requests?
// Update user profile
this.http.put('api/users/10', updatedUser).subscribe(() => {
// Delete old profile picture
this.http.delete('api/pictures/oldPicId').subscribe(() => {
console.log('Profile updated and old picture deleted');
});
});
hard
A. DELETE request first to delete picture, then PUT request inside DELETE's subscribe to update profile
B. Use only PUT request to update profile and delete picture together
C. Send PUT and DELETE requests simultaneously without waiting for response
D. PUT request first to update profile, then DELETE request inside PUT's subscribe to delete picture
Solution
Step 1: Understand request order
First update the user profile with PUT, then delete the old picture after success.
Step 2: Analyze code structure
DELETE request is inside PUT's subscribe callback, ensuring sequential execution.
Step 3: Evaluate other options
Deleting first may remove picture before profile update; simultaneous calls lack order; PUT cannot delete picture.
Final Answer:
PUT request first to update profile, then DELETE request inside PUT's subscribe to delete picture -> Option D
Quick Check:
Update then delete sequentially = B [OK]
Hint: Chain DELETE inside PUT subscribe for correct order [OK]
Common Mistakes:
Deleting before updating causing data mismatch
Sending requests simultaneously without order
Trying to delete picture with PUT request
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.