11.) What does the Accept header specify in an API request?
A) The client type
B) The server’s API version
C) The authentication type
D) The data format expected in the response
12.) How do you handle errors in a fetch() request?
A) Using try…catch blocks or then().catch() methods
B) Using fetchError() function
C) Using the error property of the response
D) Errors cannot be handled in fetch()
13.) What is the output of response.ok in a fetch() API call if the request is successful?
A) “ok”
B) true
C) 1
D) null
14.) Which function can convert an API response from JSON to JavaScript objects?
A) JSON.stringify()
B) JSON.decode()
C) response.json()
D) response.parse()
15.) What is the purpose of the Authorization header in API requests?
A) To specify data format
B) To include authentication credentials
C) To specify the API version
D) To set request priority
16.) Which HTTP method is typically used for sending data to an API?
A) POST
B) GET
C) DELETE
D) OPTIONS
17.) What is the purpose of an API key in requests?
A) To encrypt the request data
B) To indicate the request priority
C) To specify the API version
D) To authenticate the client
18.) Which of the following is a commonly used library for making API requests in JavaScript?
A) jQuery
B) Axios
C) D3.js
D) Lodash
19.) What happens when a fetch() request encounters a network error?
A) Throws a TypeError
B) Returns undefined
C) Continues execution without errors
D) Returns an empty object
Related