Quiz Space

Modern Application Development II · End Term · 1 Sept 2024 · May 2024 term

Question 27: Consider the below JavaScript code. Suppose the API URL …

Question 27

+4.5 marksOne correct option

Consider the below JavaScript code.

javascript
async function newFetch(url) {
try {
console.log(url)
const res = await fetch(url)
if (!res.ok) {
throw new Error(`HTTP Error: ${res.status}`)
}
try {
const data = await res.json()
console.log(data)
} catch {
throw new Error('Error')
}
} catch {
throw new Error('Data is not JSON serializable')
}
}
newFetch('https://example.com/api/users/23').catch((err) => {
console.error(err)
})

Suppose the API URL “https://example.com/api/users/23” returns a valid HTML output. What will be logged on to console?

  1. A

    “Network Error”

  2. B

    “HTTP Error: 404”

  3. C

    “Data is not JSON serializable”

  4. D

    Data returned by the API

Show answer

Correct answer

  • C

    “Data is not JSON serializable”

Question 27 of 32 in the IIT Madras BS Modern Application Development II (MAD 2) End Term paper sat on 1 Sept 2024, in the May 2024 term (IIT M FOUNDATION DIPLOMA FN EXAM QDF1 01 Sep 2024). It carries 4.5 marks.

More questions from this paper

  1. Q1What of the following is the primary objective of a CSRF token?
  2. Q2Suppose an application is being loaded from the origin https://example.com. Which of the following origins will the bro…
  3. Q3What is the correct sequence of steps to update the state in Vuex when handling an asynchronous operation?
  4. Q4Suppose you are developing an application for millions of users that will perform intensive data analysis and return th…
  5. Q5Which of the following statements about Redis is true?
  6. Q6Which of the following scenarios is an example of a Cross-Site Request Forgery (CSRF) attack?
  7. Q7Match the following technologies with their typical use cases:
  8. Q8Consider the below javascript program. What will be the output of the above program, if executed?
  9. Q9Consider the following JavaScript code snippet. What will be the values of 'storedUsername', 'removedUsername', and 'cl…
  10. Q10Consider the following javascript code What are the values of regularResult and arrowResult?
  11. Q11Consider the below 2 approaches: Approach 1: Approach 2: Choose the correct statement:
  12. Q12Consider the below JavaScript program. What will be the output of the above program, if executed? Also, predict the min…
  13. Q13Which of the following statement(s) is/are true about webhooks?
  14. Q14Which of the following statement(s) is/are true regarding javascript?
  15. Q15Which of the following scenarios are best suited for using Celery tasks?
  16. Q16Which of the following statements is/are true regarding webhooks and server sent events (SSE)?
  17. Q17Which of the following is/are the correct ways to achieve the following.\ Always apply class named “errorClass”,\ The c…
  18. Q18Which of the following is/are true about Server-Sent Events (SSE)?
  19. Q19Which of the following HTTP header(s) can be used to control caching behavior in web applications?
  20. Q20Which of the following statement(s) is/are true regarding long and short polling?
  21. Q21Consider the following Vue.js 2 component using CDN. After entering "Orange" in the input box and clicking the "Add" bu…
  22. Q22Consider the following javascript code running on browser What will be the output in the browser console?
  23. Q23Consider the below JavaScript program. What will be the output of the above program?
  24. Q24Consider the below flask application. If the application is running on “http://127.0.0.1:5000” and the user visits the …
  25. Q25Consider the below JavaScript program. What will be the output of the above program?
  26. Q26In a Vue CLI project with Vuex, you have the following configuration: src/store/index.js: src/App.vue: After running “n…
  27. Q28Consider the following Flask application with Redis caching. Redis is running normally on port 6379. Two requests are g…
  28. Q29Which code snippet represents a Webhook receiver implementation?
  29. Q30Which code snippet represents a Pub/Sub implementation?
  30. Q31Filename: script.js
  31. Q32Filename: script.js