The error Status Code 401
happens when you make a request, but you do not have permission.
Already the error quoted in the previous response comment:
"Failed to load infomoney.com.br/blogs/investimentos/off-the-records/rss: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost'; is therefore not allowed access."
It happens because the header Access-Control-Allow-Origin
is missing from the server response.
To work around this, you can use the https://cors.io/
site. It will serve as an intermediary and will automatically add the required header .
Example with Fetch:
fetch("https://cors.io/?http://www.infomoney.com.br/blogs/investimentos/off-the-records/rss")
.then( resp => resp.text() )
.then(resp => console.log(resp))
.catch( err => console.debug(err) );
Example with XHR:
var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(ajax.responseText);
}
};
ajax.open("GET", "https://cors.io/?http://www.infomoney.com.br/blogs/investimentos/off-the-records/rss", true);
ajax.send();