Which method returns a promise that resolves with the result of parsing the body text as JSON?
- .json() method
- .text() method
- .body() method
- .parseJSON() method
The .json() method of a Response object returned by fetch parses the response body text as JSON and returns a Promise that resolves with the parsed data. This method is commonly used when making API requests to obtain structured data in JSON format. The .text() method returns the response body as plain text, while .body() does not exist, and .parseJSON() is not a standard method in JavaScript.
Loading...
Related Quiz
- How can you prevent script injection attacks when dynamically modifying element content with user input?
- What is the main difference between stopPropagation and stopImmediatePropagation?
- Unlike function expressions, function declarations are _________.
- You are reviewing a junior developer's code and see the following line var x = 10;. You want to advise them to use a declaration that maintains block scope, which keyword should they use instead of var?
- What is lexical scoping in JavaScript?