I wanted to know how I can use the fetch()
function in javascript to return the source of a page from a different origin. I already know that if you want to get the HTML source you do something like this:
const getData = async () => {
const res = await fetch('http://example.com')
const data = await res.text()
console.log(data)
}
When I tried using the above function, I got a cors error. I then tried adding, {mode: 'no-cors'}
to the options but, that didn't return any response. I have done some research and found nothing useful. Is it possible to get the source of a website from a cross-origin request? Thanks.