XJavascript.com
Toggle Menu
Home
Online Javascript Compiler
Tutorials
JavaScript Tutorials
TypeScript Tutorials
Blog
All Posts
Web APIs and Fetch
Check your ability to use Fetch,Axios,and RESTful APIs with JavaScript.
1. What is the default HTTP method used by the Fetch API when no method is specified?
GET
POST
PUT
DELETE
2. Which of the following are considered standard Web APIs available in modern browsers?
Fetch API
Node.js API
Geolocation API
Web Storage API
3. The Fetch API returns a Promise that resolves only if the HTTP request is successful (e.g., 200 status).
True
False
4. What does CORS stand for? (spelled out)
5. Which method is used to parse a JSON response body in the Fetch API?
response.parseJSON()
response.json()
JSON.parse(response)
response.body.json()
6. Which options are commonly included in a Fetch request configuration object for a POST request?
method: 'POST'
body
headers
sync: true
7. The Fetch API can only make requests to the same origin as the current page.
True
False
8. What is the purpose of the `mode` option in the Fetch API configuration?
To set the request timeout
To control CORS behavior
To specify the cache policy
To enable request retries
9. Name the browser API that allows accessing the user's geographical location (abbrev.).
10. Which of the following are valid response methods in the Fetch API for handling different data types?
response.text()
response.blob()
response.arrayBuffer()
response.formData()
11. When using `async/await` with Fetch, you must wrap the `fetch()` call in a `try/catch` block to handle errors.
True
False
12. What does the `response.ok` property return?
A boolean indicating if the response status is 2xx (success)
The HTTP status code (e.g., 200, 404)
The response body as a string
The request URL
13. What is the term for the practice of making multiple independent Fetch requests and waiting for all of them to complete before proceeding?
14. Which headers are commonly set when sending JSON data in a POST request with Fetch?
Content-Type: application/json
Accept: application/json
Authorization: Bearer <token>
Cache-Control: no-cache
15. The Fetch API is a replacement for XMLHttpRequest (XHR).
True
False
16. What is the default `credentials` option for a Fetch request?
include
omit
same-origin
credentials
17. What is the abbreviation for the API that allows storing key-value pairs in the browser with no expiration time?
18. Which of the following are valid ways to handle a Fetch response using promises?
.then(response => response.json())
async () => { const response = await fetch(url); }
fetch(url).catch(error => console.error(error))
response.onload = function() {}
19. CORS errors occur only when making requests from a browser to a different origin; they do not occur in server-side code.
True
False
20. Which Web API is used to interact with the browser's URL bar and navigation history?
History API
Location API
URL API
Fetch API
Reset
Answered 0 of 0 — 0 correct