Bird
0
0

Given this API request code snippet, what will be the output if the token is missing?

medium📝 Predict Output Q13 of 15
Rest API - API Documentation
Given this API request code snippet, what will be the output if the token is missing?
fetch('https://api.example.com/data', {
  headers: { 'Authorization': 'Bearer ' }
})
.then(response => response.status)
.then(status => console.log(status));
A401
B404
C500
D200
Step-by-Step Solution
Solution:
  1. Step 1: Understand missing token effect

    When the token is missing or empty, the server usually rejects the request as unauthorized.
  2. Step 2: Identify HTTP status code for unauthorized

    The standard status code for unauthorized access is 401.
  3. Final Answer:

    401 -> Option A
  4. Quick Check:

    Missing token = 401 Unauthorized [OK]
Quick Trick: Missing token causes 401 Unauthorized error [OK]
Common Mistakes:
MISTAKES
  • Assuming missing token returns 200 OK
  • Confusing 401 with 404 Not Found
  • Thinking server returns 500 error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes