Here are some good resources for fetch and an example.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
https://developer.mozilla.org/en-US/docs/Web/API/Body/text
https://developer.mozilla.org/en-US/docs/Web/API/Body/json
You may also want to get familiar with promises.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
function doSomethingWithText(text) {
console.log('The text is:', text);
}
fetch('someUrl.html')
.then(data => data.text())
.then(text => (doSomethingWithText(text))
.catch(error => new Error(error));