How does the Fetch API handle HTTP error statuses (like 404 or 500) in Promises?
- It doesn't reject the Promise for any HTTP error status
- It rejects the Promise only for network errors
- It rejects the Promise for any non-2xx HTTP status
- It triggers a catch block for network errors and HTTP errors
The Fetch API rejects the Promise for any non-2xx HTTP status, allowing developers to handle errors more effectively. Network errors, however, are still caught separately, providing detailed error handling in both scenarios.
Loading...
Related Quiz
- How do you remove an item from a Map in ES6?
- When creating a utility class with common helper functions, how would you ensure that these methods are accessible without instantiating the class?
- Tagged template literals allow you to parse template literals with a _________ function.
- Which method is used to handle errors in a JavaScript Promise?
- What is the primary role of the call stack in JavaScript execution?