Bird
0
0

What is wrong with this Angular DELETE request?

medium📝 Debug Q6 of 15
Angular - HTTP Client
What is wrong with this Angular DELETE request?
this.http.delete('/api/items', 5).subscribe();
ADELETE requests cannot have a URL parameter
BThe second argument should be an options object, not a number
Csubscribe() must have a callback function
DThe URL should not contain '/api/items'
Step-by-Step Solution
Solution:
  1. Step 1: Check HttpClient.delete signature

    The second argument is an options object, not a direct ID.
  2. Step 2: Correct usage

    To delete item with ID 5, the URL should be '/api/items/5' and options can be passed as an object.
  3. Final Answer:

    The second argument should be an options object, not a number -> Option B
  4. Quick Check:

    Second argument must be options object [OK]
Quick Trick: DELETE second argument is options object, not ID [OK]
Common Mistakes:
MISTAKES
  • Passing ID as second argument instead of in URL
  • Omitting subscribe callback
  • Misunderstanding URL structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes