I'm trying to do a fetch request to example.com, and trying to get a specific ElementID from the fetched webpage into the console log without success.
I've tried the following code without success yet:
const url = "https://example.com";
fetch(url)
.then(response => response)
.then(data => {
const resData = data.text();
console.log(resData);
document.getElementById("id").innerHTML = resData;
})
.catch((err) => console.log("Can’t access " + url + " response. Blocked by browser?" + err));
I'll be for your suggestions'. Thanks
I'm getting TypeError: Cannot set property 'innerHTML' of null