Response object returned by the
fetch() method contains the information about the request and the response of the network request, including headers, status codes, and status messages.
Response object provides several methods to access the response body like
text(), and more. You can use the
text() method to get the response as an HTML string.
Here is an example that downloads the Google homepage as an HTML string and prints it on the console:
fetch('https://www.google.com') .then(res => res.text()) .then(res => console.log(res)) .catch(err => console.error(err))
text() method returns the response body as a string. Read this article to learn more about Fetch API response formats.