When I have a fetch call with multiple then functions, I encounter an issue. Specifically, in one of the then functions, I am trying to pass two returned variables to the next then function, but it does not seem to work as expected.
.then(text => {
let content = new DOMParser().parseFromString(text, "text/html");
let main = content.querySelector('main').innerHTML;
let title = content.querySelector('title').innerHTML;
function retrieveHtml() {
return {
main, title
}
}
})
.then(retrieveHtml => {
let parsedHtml = retrieveHtml();
document.querySelector('main').innerHTML = parsedHtml.main;
document.title = parsedHtml.title;
})
Encountering the error "is not a function error" when accessing the retrieveHtml() function within the last then(). Any tips would be greatly appreciated!