Bird
0
0

Given this JavaScript fetch code:

medium📝 Predict Output Q5 of 15
Rest API - HTTP Methods
Given this JavaScript fetch code:
fetch('/api/products/10', { method: 'DELETE' })
  .then(response => response.status)
  .then(status => console.log(status));

What status code will be logged if the product with ID 10 is deleted successfully?
A200
B204
C404
D500
Step-by-Step Solution
Solution:
  1. Step 1: Understand typical DELETE responses

    Successful DELETE often returns 204 No Content indicating success without body.
  2. Step 2: Differentiate from other codes

    200 OK is possible but 204 is preferred; 404 means not found; 500 is server error.
  3. Final Answer:

    204 -> Option B
  4. Quick Check:

    Successful DELETE usually returns 204 [OK]
Quick Trick: Successful DELETE returns 204 No Content [OK]
Common Mistakes:
MISTAKES
  • Expecting 200 OK instead of 204
  • Confusing 404 Not Found with success
  • Assuming server error codes on success

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes